[go-nuts] When to use custom string type and custom int type

2017-08-03 Thread Kaviraj Kanagaraj
Can someone help me understand whats the main difference two different UserType in below snippet.? More importantly when to use which. ``` type UserType string const ( Undefined UserType = "undefined" Admin UserType = "admin" ) type UserType int const ( Undefined UserType = iota Admin )

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-05 Thread Kaviraj Kanagaraj
pass an interface as a > different interface, the static information of what methods are on that > interface gets erased. If you want to preserve this type information, you > need to pass a non-interface type (such as a pointer to an interface). > * Usage of reflect is subtle and

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Kaviraj Kanagaraj
Sry for the typo. Its true that Kind() returns "Invalid" if IsValid returns False. But still docs seems to be misleading. It says "If v is the zero Value (IsValid returns false), Kind returns Invalid." according to doc, all the variables in the code supposed to have a kind of "Invalid" (since a

[go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Kaviraj Kanagaraj
doc for Value.Kind() says, "If v is the zero Value (IsValid returns false), Kind returns Invalid." but thats not true. I does return "Invalid" in case of interfaces. but not for every type. It doesn't return "invalid" even if IsValid return false. https://play.golang.org/p/wrVwCedf65 -- You