https://github.com/nixihz/protoc-gen-go-enum
A protoc plugin allow to generate const and map from proto and its comment.
https://github.com/nixihz/protoc-gen-go-enum
protoc-plugin
Last synced: 5 months ago
JSON representation
A protoc plugin allow to generate const and map from proto and its comment.
- Host: GitHub
- URL: https://github.com/nixihz/protoc-gen-go-enum
- Owner: nixihz
- Created: 2022-10-14T01:54:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-15T05:32:58.000Z (over 3 years ago)
- Last Synced: 2024-06-20T13:34:34.069Z (about 2 years ago)
- Topics: protoc-plugin
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# protoc-gen-go-enum
Allow to generate const and map from proto and its comment.
### Installation
```shell
go install github.com/nixihz/protoc-gen-go-enum
```
### Usage
```shell
protoc --go-enum_out=paths=source_relative:./ \
--go-enum_opt=paths=source_relative \
example/example.proto
```
### Example
from
```protobuf
// Platform Enum
enum Platform{
// Android OS
ANDROID = 0;
// iOS
IOS = 1;
}
```
to
```go
// 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",
}
)
```