golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.78k stars 1.58k forks source link

types/known: functions for working with FieldMask #398

Closed zombiezen closed 4 years ago

zombiezen commented 7 years ago

ptypes has convenience functions for most of the well-known types (WKT), except for FieldMask. This issue tracks adding functions to manipulate field masks.

jgiles commented 7 years ago

I'm not certain what precisely you include when you say "functions to manipulate field masks", but it would be nice to have the functionality available in Java for merging based on field masks available in Go: https://github.com/google/protobuf/blob/master/java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java

zombiezen commented 7 years ago

Yup! That's what we're talking about. :smiley:

zllak commented 6 years ago

Wouldn't it be possible to change the regen.sh script to build the field_mask.proto, without having the methods to manipulate it ? It's a real pain in go to use the FieldMask, you'll have to get it from github.com/google/go-genproto/protobuf or google.golang.org/genproto/protobuf/field_mask

nclinger commented 6 years ago

Any update on this mr @zombiezen ?

dsnet commented 6 years ago

We're in the process of making large-scale improvements to Go protobufs. For now, I think we should hold off on additional API for this. I recognize that this is a painpoint for some people, but there's nothing preventing someone from writing a 3rd-party package to wrap this behavior.

dsnet commented 6 years ago

I should also note that field mask currently lives outside this repo: https://godoc.org/google.golang.org/genproto/protobuf/field_mask

We probably want to resolve #218 first.

anand-mundada commented 5 years ago

Any update on this? Do we have any recommended util/library method for Go?

wkiser commented 5 years ago

@anand-mundada it's not an official library, but I have successfully been using https://github.com/mennanov/fieldmask-utils until there is an official library.

dsnet commented 4 years ago

Fixed by https://golang.org/cl/225298. It will be available in the next release of the google.golang.org/protobuf module, to be released within a week or so.

dsnet commented 4 years ago

I should note that there isn't any functionality for using a FieldMask with merging or serialization to filter in/out fields in a message. That's to come in a future change as there is significant technical work that goes into it.