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 said. Create a string type and define your > constants with that type, but I'd create a more specific meaningful type > rather than a generic Enum. > > For example: > > > type UserType string > > const ( > Admin UserType = "administrator" > RegularUser = "regular user" > ..... > ) > > Note that you only need to define the type for the first const definition > in the block. > > Hope it helps. > > - RK > > > On Thu, Nov 28, 2013 at 3:50 AM, bronze man <bronz...@gmail.com > <javascript:>> wrote: > >> type Enum string >> >> const ( >> EnumAbc Enum = "abc" >> EnumDef Enum = "def" >> ) >> This type work fine with json. >> >> >> On Thursday, November 28, 2013 5:48:47 PM UTC+8, Péter Szilágyi wrote: >>> >>> Hi all, >>> >>> This might be a bit unorthodox question, but I thought I'd ask away >>> anyway :D Is there a straightforward possibility to assign string >>> representations to an enumeration inline (i.e. at the point of declaring >>> the enum), or possibly getting the original source code string back? >>> >>> E.g. I have an enumeration like: >>> >>> const ( >>> Abc = iota >>> Def >>> Ghi >>> Etc >>> ) >>> >>> And during debugging or just logging when I dump my structs containing >>> these, I'd like to have a textual representation oppose to an int (mainly >>> because I have many tens of entries, and manual lookup is bothersome). >>> >>> Of course, I could map the ints to strings, but I'm wondering if there >>> is something simpler, similar to tagging a struct field with a json name... >>> i.e. >>> >>> type S struct{ >>> Address string `json:"address"` >>> } >>> >>> If not, it's not really an issue, I'm just curious :) >>> >>> Thanks, >>> Peter >>> >> -- >> 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 golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.