idodod / protoc-gen-fieldmask Goto Github PK
View Code? Open in Web Editor NEWA protoc plugin that generates fieldmask paths
License: MIT License
A protoc plugin that generates fieldmask paths
License: MIT License
I've built and installed the tool. Then using buf:
# buf.gen.yaml
# Generated by "buf config migrate-v1beta1". Edit as necessary, and
# remove this comment when you're finished.
version: v1
plugins:
- name: go
out: .
opt: paths=source_relative
- name: go-grpc
out: .
opt: paths=source_relative
- name: fieldmask
out: .
And running
โ buf generate -o pkg/proto
Failure: plugin fieldmask: github.com/<repo>/../<filename>.pb.fieldmask.go: unparsable Go source: 296:1: expected '}', found 'type' (and 9 more errors)
I'm sorry I can't provide a narrower concrete example right now.
Let's add generation full path generator, which will generate path from message name to field name.
Problem: for example in one proto file can be several duplicated field names:
syntax = "proto3";
package casesa;
option go_package = "cases/a;a";
message Foo {
string bar = 1;
int32 baz = 2;
}
message Bar {
string bar = 1;
}
After generation we will receive smth like this:
f := Foo{}
f.FieldMaskPaths().Bar() // will return "bar"
b := Bar{}
b.FieldMaskPaths().Bar() // will also return "bar"
It is a problem due to one proto file can be like namespace. So it can be useful to have absolute path of each field in namespace.
f := Foo{}
f.FullFieldMaskPaths().Bar() // will return "foo.bar"
b := Bar{}
b.FullFieldMaskPaths().Bar() // will return "bar.bar"
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: .github/renovate.json5
Error type: Invalid JSON5 (parsing failed)
Message: JSON5.parse error: JSON5: invalid character '}' at 62:5
For example if you will try to generate field mask from such proto file:
syntax = "proto3";
option go_package = "unparsable";
package unparsable;
message Foo {
string type = 1;
string switch = 2;
}
You will get an error:
--fieldmask_out: t.pb.fieldmask.go: unparsable Go source: 41:64: expected selector or type assertion, found 'type' (and 4 more errors)
So the problem is that if you use as a field name reserved word in Goland - it will be an error.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
google.golang.org/genproto
, google.golang.org/protobuf
).github/workflows/ci.yml
actions/checkout v4
nelonoel/branch-name v1.0.1
.github/workflows/release.yml
actions/checkout v4
nelonoel/branch-name v1.0.1
earthly/actions v1
go.mod
go 1.22
github.com/iancoleman/strcase v0.3.0
github.com/stretchr/testify v1.9.0
google.golang.org/genproto v0.0.0-20240429193739-8cf5692501f6@8cf5692501f6
google.golang.org/protobuf v1.34.0
.github/renovate.json5
Earthfile
go 1.22
Earthfile
alpine 3.19
Earthfile
golangci/golangci-lint v1.58.0
Earthfile
namely/protoc-all 1.51_2
.github/workflows/ci.yml
earthly/earthly v0.8.9
.github/workflows/release.yml
earthly/earthly v0.8.9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.