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
)
func (u UserType) String() string {
switch u {
case Undefined:
return "undefined"
case Admin:
return "admin"
}
return "UserType" + strconv.Itoa(int(u))
}
```
Some obvious differences including
1. More memory usage in case string based type
2. Usefull zero-value in case of int based type.
I just wanted to know is there any rule of thumb to decide when to use
which.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.