Skip to content

A protoc plugin allow to generate const and map from proto and its comment.

Notifications You must be signed in to change notification settings

nixihz/protoc-gen-go-enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-gen-go-enum

Allow to generate const and map from proto and its comment.

Installation

go install github.com/nixihz/protoc-gen-go-enum

Usage

protoc --go-enum_out=paths=source_relative:./ \
    --go-enum_opt=paths=source_relative \
    example/example.proto

Example

from

// Platform Enum
enum Platform{
    // Android OS
    ANDROID = 0;
    // iOS
    IOS = 1;
}

to

// Platform Enum
const (
    Platform_ANDROID int64 = 0 // Android OS
    Platform_IOS     int64 = 1 // iOS
)

var (
    Platform_TXT = map[int64]string{
        Platform_ANDROID: "Android OS",
        Platform_IOS:     "iOS",
    }
)

About

A protoc plugin allow to generate const and map from proto and its comment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published