import "golang.org/x/tools/go/types" func main() { var s []int elemType := types.Elem(types.NewSlice(types.Typ[types.Int])) fmt.Println(elemType) // int }
import "golang.org/x/tools/go/types" func main() { var a [5]string elemType := types.Elem(types.NewArray(types.Typ[types.String], 5)) fmt.Println(elemType) // string }These code examples use the golang.org/x/tools/go/types package library.