Skip to content
Permalink
Browse files

Add FieldMask demo method

  • Loading branch information
johanbrandhorst committed Apr 2, 2018
1 parent 807d213 commit 6c217371b67a89609c632f047477fa5a1123ac93
@@ -27,18 +27,21 @@ generate:
--gogo_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api:\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src/ \
--grpc-gateway_out=\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api:\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src/ \
--swagger_out=third_party/OpenAPI/ \
--govalidators_out=gogoimport=true,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api:\
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:\
$$GOPATH/src \
proto/example.proto

3 comments on commit 6c21737

@wolfinger

This comment has been minimized.

Copy link

@wolfinger wolfinger replied Jan 25, 2021

i'm trying to replicate this for my own app and am getting the following compile error: generated/api/v1/acct_service.pb.gw.go:128:24: cannot use fieldMask (type *fieldmaskpb.FieldMask) as type *types.FieldMask in assignment

i believe the issue might be related to grpc-ecosystem/grpc-gateway#812 where the grpc gateway will automatically populate a fieldmask using the json request. that fieldmask type is using the standard protobuf fieldmask type while gogo is using an identically structured, but different fieldmask type.

please note i'm a go beginner and programming is not my day job, so apologize if i'm missing something obvious or not using correct terminology.

@johanbrandhorst

This comment has been minimized.

Copy link
Member Author

@johanbrandhorst johanbrandhorst replied Jan 25, 2021

Hi @wolfinger, I wrote a blog post about these sort of errors a while back: https://jbrandhorst.com/post/gogoproto/. My recommendation nowadays is just to avoid using gogo protobuf altogether. You can make it work but there are both obvious and non obvious warts in the process and it's not worth the potential speed increase.

@wolfinger

This comment has been minimized.

Copy link

@wolfinger wolfinger replied Jan 25, 2021

super helpful @johanbrandhorst, thanks so much. looks like it's time for a refactor!

Please sign in to comment.