go - How do I get Type -


i'd (reflect)type type name.
http://play.golang.org/p/c-9ipsafx0

package main  import (     "fmt"     "reflect" )  type name string  func main() {     fmt.println("hello, playground")      var name name = "taro"     fmt.println(name)      fmt.println(gettype(name))     // fmt.println(gettype(name))  // want same gettype(name) }  func gettype(v interface{}) reflect.type {     return reflect.typeof(v) } 

how rewrite gettype function.

there no way pass type argument function in go, ask not possible. if want use reflect module work types, need have value starting point.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

node.js - StackOverflow API not returning JSON -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -