diff --git a/cmd/protoc-gen-go-vtproto/main.go b/cmd/protoc-gen-go-vtproto/main.go index 0f0016e..6f9209e 100644 --- a/cmd/protoc-gen-go-vtproto/main.go +++ b/cmd/protoc-gen-go-vtproto/main.go @@ -19,9 +19,10 @@ import ( func main() { var cfg generator.Config var features string - var f flag.FlagSet + f.BoolVar(&cfg.AllowEmpty, "allow-empty", false, "allow generation of empty files") + cfg.Poolable = make(generator.ObjectSet) f.Var(&cfg.Poolable, "pool", "use memory pooling for this object") f.BoolVar(&cfg.Wrap, "wrap", false, "generate wrapper types") f.BoolVar(&cfg.WellKnownTypes, "wkt", true, "generate optimized code for well-known types") diff --git a/generator/generator.go b/generator/generator.go index 3e520d4..d3afaa2 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -22,11 +22,11 @@ type featureHelpers struct { type ObjectSet map[protogen.GoIdent]bool -func (o *ObjectSet) String() string { - return fmt.Sprintf("%#v", *o) +func (o ObjectSet) String() string { + return fmt.Sprintf("%#v", o) } -func (o *ObjectSet) Set(s string) error { +func (o ObjectSet) Set(s string) error { idx := strings.LastIndexByte(s, '.') if idx < 0 { return fmt.Errorf("invalid object name: %q", s) @@ -37,10 +37,7 @@ func (o *ObjectSet) Set(s string) error { GoName: s[idx+1:], } - if o == nil { - *o = make(ObjectSet) - } - (*o)[ident] = true + o[ident] = true return nil }