diff --git a/enumer.go b/enumer.go index 8f92f58..45ac04e 100644 --- a/enumer.go +++ b/enumer.go @@ -61,7 +61,7 @@ func (g *Generator) buildBasicExtras(runs [][]Value, typeName string, runsThresh g.Printf("\nvar _%sValues = []%s{", typeName, typeName) for _, values := range runs { for _, value := range values { - g.Printf("\t%s, ", value.str) + g.Printf("\t%s, ", value.originalName) } } g.Printf("}\n\n") @@ -98,8 +98,8 @@ func (g *Generator) printValueMap(runs [][]Value, typeName string, runsThreshold } for _, value := range values { - g.Printf("\t_%sName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), &value) - g.Printf("\t_%sLowerName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), &value) + g.Printf("\t_%sName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), value.originalName) + g.Printf("\t_%sLowerName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), value.originalName) n += len(value.name) } } diff --git a/stringer.go b/stringer.go index 60e19c2..81cd84c 100644 --- a/stringer.go +++ b/stringer.go @@ -508,7 +508,8 @@ func (g *Generator) format() []byte { // Value represents a declared constant. type Value struct { - name string // The name of the constant after transformation (i.e. camel case => snake case) + originalName string // The name of the constant before transformation + name string // The name of the constant after transformation (i.e. camel case => snake case) // The value is stored as a bit pattern alone. The boolean tells us // whether to interpret it as an int64 or a uint64; the only place // this matters is when sorting. @@ -602,10 +603,11 @@ func (f *File) genDecl(node ast.Node) bool { u64 = uint64(i64) } v := Value{ - name: n.Name, - value: u64, - signed: info&types.IsUnsigned == 0, - str: value.String(), + originalName: n.Name, + name: n.Name, + value: u64, + signed: info&types.IsUnsigned == 0, + str: value.String(), } if c := vspec.Comment; f.lineComment && c != nil && len(c.List) == 1 { v.name = strings.TrimSpace(c.Text())