gop
gop copied to clipboard
Introduce builtin function: type
In Go, we use reflect.TypeOf to get type of a value:
tyInt := reflect.TypeOf(int(0))
tyEmptyInterface := reflect.TypeOf((*interface{})(nil)).Elem() // no easy way to get an interface type
We may can introduce a type function to simplify it:
tyInt := type(int)
tyEmptyInterface := type(interface{})
mayb be typeOf is an alternate choice. But I'm not very sure about this feature, it seems not very necessary.
we can move this faction to another lib package, like "reflects".
we can move this faction to another lib package, like "reflects".
Because we use types as parameters, it is not a normal function. It has to be a builtin function like new.