Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-26 Thread Tong Sun
The problem of all code I've seen so far is that they are all demonstrate half the solution, i.e., the conversion goes one way. I know it's an easy fix, but none the less, for me it's still half solution, because I need to get and *validate *the enum as *user input* from command line, but use s

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-26 Thread Edward Muller
FWIW, I wouldn't use an "enum" (those don't exist in go) and would probably do something like this: https://play.golang.org/p/J6_hssueao On Wed, Apr 26, 2017 at 11:41 AM Tong Sun wrote: > > > On Tuesday, April 25, 2017 at 4:25:14 PM UTC-4, Tong Sun wrote: >> >> >> On Tue, Apr 25, 2017 at 3:42 P

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-26 Thread Tong Sun
On Tuesday, April 25, 2017 at 4:25:14 PM UTC-4, Tong Sun wrote: > > > On Tue, Apr 25, 2017 at 3:42 PM, Egon wrote: > > I think the extra "enum" package would reduce readability. The code you >> are putting into package is ~10 lines of code... so the extra package >> doesn't reduce much typing,

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Egon
On Tuesday, 25 April 2017 23:25:14 UTC+3, Tong Sun wrote: > > > On Tue, Apr 25, 2017 at 3:42 PM, Egon wrote: > > I think the extra "enum" package would reduce readability. The code you >> are putting into package is ~10 lines of code... so the extra package >> doesn't reduce much typing, but it

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Tong Sun
On Tue, Apr 25, 2017 at 3:42 PM, Egon wrote: I think the extra "enum" package would reduce readability. The code you are > putting into package is ~10 lines of code... so the extra package doesn't > reduce much typing, but it also loses enum typing... Depending on the enum, > you may want to have

Re: [go-nuts] Re: Assign a string representation to an enum/const

2016-10-25 Thread yashronaldo07
I tried this thing but it doesn't work. In my example the type for Count is displayed as AggregationFuncEnum, but for Sum it is only string. https://play.golang.org/p/ioemgmE0Sm On Thursday, November 28, 2013 at 11:52:20 PM UTC+5:30, Rodrigo Kochenburger wrote: > > I'm gonna second what bronze s