Type alias, and custom type difference
Custom Types
// custom type is to define a new type // will MyInt defined as int type of the type MyInt int
Type alias
// type alias provisions: TypeAlias only Type an alias, in essence, TypeAlias and Type are the same type. = typeAlias of the type Type of the type byte = uint8 of the type Rune = Int32
the difference
Type alias type definition is only one difference between the surface of the equal sign
// type definition type NewInt int // type alias type MyInt = int FUNC main () { var A NewInt var B MyInt fmt.Printf ( " type of A: T% \ n- " , A) // type of A: main .NewInt fmt.Printf ( " type of B:% T \ n- " , B) // type of B: int }
// difference
// display a result of the typemain.NewInt
showing the main package definedNewInt
type. b type isint
.MyInt
Type in the code will only exist when there is not compiledMyInt
types.