Fmutils
Golang protobuf FieldMask missing utils
Install / Use
/learn @mennanov/FmutilsREADME
Golang protobuf FieldMask utils
Filter a protobuf message with a FieldMask applied
// Keeps the fields mentioned in the paths untouched, all the other fields will be cleared.
fmutils.Filter(protoMessage, []string{"a.b.c", "d"})
Prune a protobuf message with a FieldMask applied
// Clears all the fields mentioned in the paths, all the other fields will be left untouched.
fmutils.Prune(protoMessage, []string{"a.b.c", "d"})
Merge protobuf messages with a FieldMask applied
// Overwrites the fields in the dst from src.
// Only the fields listed in the field mask will be copied.
fmutils.Overwrite(src, dst, []string{"a.b.c", "d"})
Working with Golang protobuf APIv1
This library uses the new Go API for protocol buffers.
If your *.pb.go files are generated with the old version APIv1 then you have 2 choices:
- migrate to the new APIv2
google.golang.org/protobuf - upgrade an existing APIv1 version to
github.com/golang/protobuf@v1.4.0that implements the new API
In both cases you'll need to regenerate *.pb.go files.
If you decide to stay with APIv1 then you need to use
the proto.MessageV2 function like this:
import protov1 "github.com/golang/protobuf/proto"
fmutils.Filter(protov1.MessageV2(protoMessage), []string{"a.b.c", "d"})
Read more about the Go protobuf API versions.
Examples
See the examples_test.go for real life examples.
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
343.1kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
