fieldmask-go

Generate helpers to construct compile time safe fieldmasks in go.

Install the plugin using,

go get github.com/srikrsna/fieldmask-go/cmd/[email protected]

Use it:

version: v1plugins:  - name: go    out: gen    opt: paths=source_relative  - name: fieldmask-go    out: gen    opt: paths=source_relative

For protobuf messages,

message Entity {    string id = 1;    SubMessage sub = 2;}message SubMessage {    string id = 1;}

This should now generate code that can be used,

fm, err := fieldmaskpb.New(    &pb.Entity{},    string(pbfieldmask.EntityMask.Id()),    pbfieldmask.EntityMask.Sub().Id(),)

GitHub

View Github