A protoc plugin that generates fieldmask paths as static type properties for proto messages

protoc-gen-fieldmask

CI GitHub release (latest SemVer) GitHub go.mod Go version License

A protoc plugin that generates fieldmask paths as static type properties for proto messages, which elimantes the usage of error-prone strings.

For example, given the following proto messages:

syntax = "proto3";

package example;

option go_package = "example/;example";

import "google/type/date.proto";

message Foo {
  string baz = 1;
  int32 xyz = 2;
  Bar my_bar = 3;
  google.type.Date some_date = 4;
}

message Bar {
  string some_field = 1;
  bool another_field = 2;
}

fieldmasks paths can be used as follows:

  foo := &example.Foo{}

  # Prints "baz"
  fmt.Println(foo.FieldMaskPaths().Baz())
  
  # Prints "xyz"
  fmt.Println(foo.FieldMaskPaths().Xyz())

  # prints "my_bar"
  fmt.Println(foo.FieldMaskPaths().MyBar().String())

  # since baz is a nested message, we can print a nested path - "my_bar.some_field"
  fmt.Println(foo.FieldMaskPaths().MyBar().SomeField())

  # thirdparty messages work the same way:
  #print "some_date"
  fmt.Println(foo.FieldMaskPaths().SomeDate().String())

  #print "some_date.year"
  fmt.Println(foo.FieldMaskPaths().SomeDate().Year())

Usage

Installation

The plugin can be downloaded from the release page, and should be ideally installed somewhere available in your $PATH.

Executing the plugin

protoc --fieldmask_out=gen protos/example.proto

# if the plugin is not in your $PATH:
protoc --fieldmask_out=out_dir protos/example.proto --plugin=protoc-gen-fieldmask=/path/to/protoc-gen-fieldmask

Parameters

The following parameters can be set by passing --fieldmask_opt to the command:

  • maxdepth: This option is relevant for a recursive message case.
    Specify the max depth for which the paths will be pregenerated. If the path depth gets over the max value, it will be generated at runtime. default value is 7.

Features

  • Currently the only supported language is go.
  • All paths are pregenerated (except for recursive messages past maxdepth).
  • Support all type of fields including repeated fields, maps, oneofs, third parties, nested messages and recursive messages.
Comments
  • Update module google.golang.org/protobuf to v1.28.1

    Update module google.golang.org/protobuf to v1.28.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | google.golang.org/protobuf | require | patch | v1.28.0 -> v1.28.1 |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/stretchr/testify to v1.8.0

    Update module github.com/stretchr/testify to v1.8.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/stretchr/testify | require | minor | v1.7.5 -> v1.8.0 |


    Release Notes

    stretchr/testify

    v1.8.0

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update go modulesUpgrades

    Update go modulesUpgrades

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/stretchr/testify | require | patch | v1.7.0 -> v1.7.5 | | google.golang.org/genproto | require | digest | 00ab72f -> 8cd45d7 | | google.golang.org/protobuf | require | minor | v1.27.1 -> v1.28.0 |


    Release Notes

    stretchr/testify

    v1.7.5

    Compare Source

    v1.7.4

    Compare Source

    v1.7.3

    Compare Source

    v1.7.2

    Compare Source

    v1.7.1

    Compare Source

    protocolbuffers/protobuf-go

    v1.28.0

    Compare Source

    Overview

    The release provides a new unmarshal option for limiting the recursion depth when unmarshalling nested messages to prevent stack overflows. (UnmarshalOptions.RecursionLimit).

    Notable changes

    New features:

    • CL/340489: testing/protocmp: add Message.Unwrap

    Documentation improvements:

    • CL/339569: reflect/protoreflect: add more docs on Value aliasing

    Updated supported versions:

    UnmarshalOption RecursionLimit
    • CL/385854: all: implement depth limit for unmarshalling

    The new UnmarshalOptions.RecursionLimit limits the maximum recursion depth when unmarshalling messages. The limit is applied for nested messages. When messages are nested deeper than the specified limit the unmarshalling will fail. If unspecified, a default limit of 10,000 is applied.

    In addition to the configurable limit for message nesting a non-configurable recursion limit for group nesting of 10,000 was introduced.

    Upcoming breakage changes

    The default recursion limit of 10,000 introduced in the release is subject to change. We want to align this limit with implementations for other languages in the long term. C++ and Java use a limit of 100 which is also the target for the Go implementation.


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ‘» Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update namely/protoc-all Docker tag to v1.51_0

    Update namely/protoc-all Docker tag to v1.51_0

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | namely/protoc-all | minor | 1.50_0 -> 1.51_0 |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency earthly/earthly to v0.6.30

    Update dependency earthly/earthly to v0.6.30

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | earthly/earthly | patch | v0.6.29 -> v0.6.30 |


    Release Notes

    earthly/earthly

    v0.6.30

    Compare Source

    Added
    • Added support for a custom .netrc file path using the standard NETRC environmental variable. #​2426
    • Ability to run multiple Earthly installations at a time via EARTHLY_INSTALLATION_NAME environment variable, or the --installation-name CLI flag. The installation name defaults to earthly if not specified. Different installations use different configurations, different buildkit Daemons, different cache volumes, and different ports.
    • New EARTHLY_CI builtin arg, which is set to true when earthly is run with the --ci flag, this ARG must be enabled with the VERSION --ci-arg feature flag. #​2398
    Changed
    • Updated buildkit to include changes up to a5263dd0f990a3fe17b67e0002b76bfd1f5b433d, which includes a change to speed-up buildkit startup time.
    • The Earthly Docker image works better for cases where a buildkit instance is not needed. The image now works without --privileged when using NO_BUILDKIT=1, and additionally, the image can also use /var/run/docker.sock or DOCKER_HOST for the buildkit daemon.
    Fixed
    • Fixed Earthly on Mac would randomly hang on 1. Init if Earthly was installed from Homebrew or the Earthly homebrew tap. #​2247
    • Only referenced ARGs from .env are displayed on failures, this prevents secrets contained in .env from being displayed. #​1736
    • Earthly now correctly detects if Podman is running but is under the disguise of the Docker CLI.
    • Improved performance when copying files. Fully-cached builds are now dramatically faster as a result. #​2049
    • Fixed --shell-out-anywhere bug where inner quotes were incorrectly removed. #​2340

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency earthly/earthly to v0.6.29

    Update dependency earthly/earthly to v0.6.29

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | earthly/earthly | patch | v0.6.28 -> v0.6.29 |


    Release Notes

    earthly/earthly

    v0.6.29

    Compare Source

    Added
    • Cache mounts sharing mode can now be specified via RUN --mount type=cache,sharing=shared via CACHE --sharing=shared. Allowed values are locked (default - lock concurrent acccess to the cache), shared (allow concurrent access) and private (create a new empty cache on concurrent access).
    Changed
    • Increases the cache limit for local and git sources from 10% to 50% to support copying large files (e.g. binary assets).
    • The default cache mount sharing mode is now locked instead of shared. This means that if you have multiple builds running concurrently, they will block on each other to gain access to the cache mount. If you want to share the cache as it was shared in previous version of Earthly, you can use RUN --mount type=cache,sharing=shared or CACHE --sharing=shared.
    Fixed
    • CACHE command was not being correctly used in IF, FOR, ARG and other commands. #​2330
    • Fixed buildkit gckeepstorage config value which was was set to 1000 times larger than the cache size, now it is set to the cache size.
    • Fixed Earthly not detecting the correct image digest for some images loaded in WITH DOCKER --load and causing cache not to be bust correctly. #​2337 and #​2288

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency earthly/earthly to v0.6.28

    Update dependency earthly/earthly to v0.6.28

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | earthly/earthly | patch | v0.6.27 -> v0.6.28 |


    Release Notes

    earthly/earthly

    v0.6.28

    Compare Source

    Added
    • A summary of context file transfers is now displayed every 15 seconds.
    • Satellite wake command, which can force a satellite to wake up (useful for calling inspect or other non-build related commands).
    Changed
    • WITH DOCKER merging of user specific /etc/docker/daemon.json settings data now applies to arrays (previously only dictionaries were supported).
    • A final warning will be displayed if earthly is terminated due to a interrupt signal (ctrl-c).
    Changed

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency golangci/golangci-lint to v1.50.1

    Update dependency golangci/golangci-lint to v1.50.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | golangci/golangci-lint | patch | v1.50.0 -> v1.50.1 |


    Release Notes

    golangci/golangci-lint

    v1.50.1

    Compare Source

    Changelog


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency earthly/earthly to v0.6.27

    Update dependency earthly/earthly to v0.6.27

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | earthly/earthly | patch | v0.6.26 -> v0.6.27 |


    Release Notes

    earthly/earthly

    v0.6.27

    Compare Source

    Changed
    • Support for all ssh-based key types (e.g. ssh-ed25519), and not only ssh-rsa. #​1783
    Fixed
    • Unable to specify public key to add via the command-line, e.g. running earthly account add-key <key> ignored the key and fellback to an interactive prompt.
    • GIT CLONE command was ignoring the WORK DIR command when --use-copy-link feature was set.

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update namely/protoc-all Docker tag to v1.50_0

    Update namely/protoc-all Docker tag to v1.50_0

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | namely/protoc-all | minor | 1.49_0 -> 1.50_0 |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update dependency earthly/earthly to v0.6.26

    Update dependency earthly/earthly to v0.6.26

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | earthly/earthly | patch | v0.6.25 -> v0.6.26 |


    Release Notes

    earthly/earthly

    v0.6.26

    Compare Source

    Added
    • Build failures now show the file and line number of the failing command
    • Introduced EARTHLY_GIT_AUTHOR and EARTHLY_GIT_CO_AUTHORS ARGS
    Fixed
    • Some network operations were being incorrectly executed with a timeout of 0.
    • Upon earthly ls failure it will display the failure reason
    Changed
    • Loading Docker images as part of WITH DOCKER is now faster through the use of an embedded registry in Buildkit. This functionality was previously hidden (VERSION --use-registry-for-with-docker) and was only auto-enabled for Earthly Satellite users. It is now enabled by default for all builds. #​1268

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update namely/protoc-all Docker tag to v1.51_1

    Update namely/protoc-all Docker tag to v1.51_1

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | namely/protoc-all | patch | 1.51_0 -> 1.51_1 |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update alpine Docker tag to v3.17

    Update alpine Docker tag to v3.17

    Mend Renovate

    This PR contains the following updates:

    | Package | Update | Change | |---|---|---| | alpine | minor | 3.16 -> 3.17 |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/stretchr/testify to v1.8.1

    Update module github.com/stretchr/testify to v1.8.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/stretchr/testify | require | patch | v1.8.0 -> v1.8.1 |


    Release Notes

    stretchr/testify

    v1.8.1

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Full path generation

    Full path generation

    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"
    
Access and modify property values in deeply nested maps, using dot-separated paths

Dig lets you access and modify property values in deeply nested, unstructured maps, using dot-separated paths: source := make(map[string]interface{})

May 7, 2022
Go-path - A helper package that provides utilities for parsing and using ipfs paths

go-path is a helper package that provides utilities for parsing and using ipfs paths

Jan 18, 2022
Code generator that generates boilerplate code for a go http server

http-bootstrapper This is a code generator that uses go templates to generate a bootstrap code for a go http server. Usage Generate go http server cod

Nov 20, 2021
Generates a random alphanumeric string of a given length.

randstring randstring.Create () is fast and has minimal memory allocation. It returns a random alphanumeric string of a given length. Install go get g

Jan 7, 2022
Generates random text based on trigrams generated from input text
Generates random text based on trigrams generated from input text

Trigrams Generates random text based on trigrams generated from input text Contents Building Running Using Implementation notes NGram size Maximum wor

Feb 9, 2022
Extract sent emojis from your Discord messages, and download them
Extract sent emojis from your Discord messages, and download them

discord-emoji-extractor Download all the emojis you've ever sent inside messages on Discord. Supports skipping duplicates and resuming downloads. Usag

Nov 7, 2022
gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.
gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.

gqlanalysis gqlanalysis defines the interface between a modular static analysis for GraphQL in Go. gqlanalysis is inspired by go/analysis. gqlanalysis

Dec 14, 2022
efaceconv - Code generation tool for high performance conversion from interface{} to immutable type without allocations.

efaceconv High performance conversion from interface{} to immutable types without additional allocations This is tool for go generate and common lib (

May 14, 2022
Type-driven code generation for Go

What’s this? gen is a code-generation tool for Go. It’s intended to offer generics-like functionality on your types. Out of the box, it offers offers

Jan 4, 2023
Go library for HTTP content type negotiation

Content-Type support library for Go This library can be used to parse the value Content-Type header (if one is present) and select an acceptable media

Jul 10, 2022
safe and easy casting from one type to another in Go

cast Easy and safe casting from one type to another in Go Don’t Panic! ... Cast What is Cast? Cast is a library to convert between different go types

Jan 1, 2023
Quickly query a Terraform provider's data type.

Terraform Query Quickly query a Terraform provider's data type. Such as a GitHub repository: ➜ ~ tfq github_repository full_name hashicorp/terraform |

Oct 12, 2021
Optional type using Go 1.18 generics.

go.eth-p.dev/goptional Generic Optional (or Go Optional, if you prefer) goptional is a package that provides an implementation of an Optional[T] monad

Apr 2, 2022
Di - A (very) WIP Go 1.18+ generic dependency injection package based on type reflection

di A (very) WIP Go 1.18+ generic dependency injection package based on type refl

Apr 26, 2022
πŸ• Enjoy a slice! A utility library for dealing with slices and maps that focuses on type safety and performance.

?? github.com/elliotchance/pie Enjoy a slice! pie is a library of utility functions for common operations on slices and maps. Quick Start FAQ What are

Dec 30, 2022
Steampipe plugin to query your Scalingo apps, addons and more

Scalingo plugin for Steampipe Use SQL to query infrastructure including applications and addons from Scalingo. Get started β†’ Documentation: Table defi

Nov 4, 2022
Helm plugin to reference value files packaged in dependency charts

Helm Octopus Plugin This Helm plugin allows to reference packaged value files (other than the default values.yaml). Install helm plugin install https:

Sep 23, 2021
Protoc-gen-fieldmask - Generate FieldMask utility functions for protobuf

protoc-gen-fieldmask Generate FieldMask utility functions for protobuf Generated

Aug 20, 2022
Create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compileCreate a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compile

Interview Assignment Overview You assignment is to create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compiler. In this ex

Nov 19, 2021
Protoc-gen-apidocs: A simple and customizable protoc generator that translates

protoc-gen-apidocs protoc-gen-apidocs is a very simple and customizable protoc g

Sep 12, 2022