Hi!
First time on the mailing-list for me, please pardon me if I am not doing this correctly.
I wanted to know if it would be possible to consider allowing to get a reflect.Type simply via the type name (not as a string value, but as a literal).
package main
import (
"fmt"
"reflect"
)
type myInterface interface{}
func main() {
var tUint reflect.Type = reflect.TypeOf(uint(0)) // current way to get a reflect.Type: create a dummy value of this type
//var tUint reflect.Type = typeReflection(uint) // what I would like to have: a built-in func, with this signature: func typeReflection(Type) reflect.Type
//var tUint reflect.Type = uint // or maybe just reference the type directly
var tInterface reflect.Type = reflect.TypeOf((*myInterface)(nil)).Elem() // even more complicated for an interface, this isn't pretty nor intuitive
//tInterface := typeReflection(myInterface) // that's a lot clearer. the func name maybe isn't the best possible, but that's a detail that can be changed
//tInterface := myInterface
fmt.Printf("Hello, playground. %q %q\n", tUint.String(), tInterface.String())
}
In addition to making my life easier (I'm working on some code generation tool), I feel like this would make sense.
What do you think?