import ( "fmt" "go/types" ) func main() { var intType types.Type = types.Typ[types.Int] fmt.Println(intType.String()) // "int" }
import ( "fmt" "go/types" ) func main() { var typeA, typeB types.Type = types.Typ[types.Int], types.Typ[types.Int] fmt.Println(types.Identical(typeA, typeB)) // true typeA, typeB = types.Typ[types.Int], types.Typ[types.Float64] fmt.Println(types.Identical(typeA, typeB)) // false }
import ( "fmt" "go/types" ) func main() { var intType types.Type = types.Typ[types.Int] fmt.Println(types.Sizeof(intType)) // 4 }Package library: This package is part of the standard Go library.