this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: map constants by go/types.Type directly

The type values make good map keys already, as they are unique for each
Go type and they can be compared. There's no need to stringify.

While here, remove an unnecessary String method call with %s.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie03fae7220158ddb45582d25e7e7c431a70328ce
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1230087
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+5 -5
+5 -5
cmd/cue/cmd/get_go.go
··· 264 264 pkg *packages.Package 265 265 orig map[types.Type]*ast.StructType 266 266 usedPkgs map[string]bool 267 - consts map[string][]string 267 + consts map[types.Type][]string 268 268 k8sSemantic bool 269 269 270 270 // per file ··· 473 473 474 474 e.recordTypeInfo(p) 475 475 476 - e.consts = map[string][]string{} 476 + e.consts = map[types.Type][]string{} 477 477 478 478 for _, f := range p.Syntax { 479 479 for _, d := range f.Decls { ··· 691 691 if n.Name == "_" { 692 692 continue 693 693 } 694 - typ := e.pkg.TypesInfo.TypeOf(n).String() 694 + typ := e.pkg.TypesInfo.TypeOf(n) 695 695 e.consts[typ] = append(e.consts[typ], n.Name) 696 696 } 697 697 } ··· 730 730 } 731 731 732 732 typ := e.pkg.TypesInfo.TypeOf(v.Name) 733 - enums := e.consts[typ.String()] 733 + enums := e.consts[typ] 734 734 name := v.Name.Name 735 735 mapNamed := false 736 736 underlying := e.pkg.TypesInfo.TypeOf(v.Type) ··· 1568 1568 } 1569 1569 1570 1570 if attrs&(required|optional) == required|optional { 1571 - return 0, fmt.Errorf("field cannot be optional and required: %s", f.String()) 1571 + return 0, fmt.Errorf("field cannot be optional and required: %s", f) 1572 1572 } 1573 1573 if attrs&required == required { 1574 1574 return attrs, nil