protoc-gen-go-enum-extractor

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

protoc-gen-go-enum-extractor

protoc-gen-go-enum-extractor is a protoc go plugin that helps you extract actual enum values with prefix removed.

An example proto package is included in the proto directory. The generated files are included in the gen directory.

Motivation

When you have a proto file with buf style enumerators like this:

enum FooBar {
    FOO_BAR_UNSPECIFIED = 0;
    FOO_BAR_A = 1;
    FOO_BAR_B = 2;
}

You will not be able to get the enum values with the prefix removed (UNSPECIFIED / A / B) directly with the generated go code. This plugin helps you extract the enum values from proto files.

Usage

  1. Install the plugin
go install github.com/jiayinzhang-mint/protoc-gen-go-enum-extractor@latest
  1. Include this plugin in your buf.gen.yaml

Parameters:

  • include_go_packages: A list of go packages with enum definitions to include.
  • unspecified_suffix: Suffix to remove from enum values (e.g. UNSPECIFIED, UNSET, etc.). Default value is UNSPECIFIED.

Note

*_UNSPECIFIED = 0 must be the first enumerator in the enum definition.

Author

Jiayin Zhang

License

Released under Apache-2.0 License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL