Skip to content

Commit

Permalink
fix protobuf enum (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee authored Apr 30, 2024
1 parent 2c6c1e1 commit 8b33bf5
Show file tree
Hide file tree
Showing 16 changed files with 335 additions and 37 deletions.
15 changes: 14 additions & 1 deletion cmds/protoc-gen-go-enum/internal/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,26 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
genFile.Line()
}

var getEnums func(msg *protogen.Message) []*protogen.Enum
getEnums = func(msg *protogen.Message) []*protogen.Enum {
var nn []*protogen.Enum
for _, enum := range msg.Enums {
nn = append(nn, enum)
}

for _, msg := range msg.Messages {
nn = append(nn, getEnums(msg)...)
}
return nn
}

for _, enum := range file.Enums {
g.Unskip()
genEnum(enum)
}

for _, msg := range file.Messages {
for _, enum := range msg.Enums {
for _, enum := range getEnums(msg) {
g.Unskip()
genEnum(enum)
}
Expand Down
4 changes: 2 additions & 2 deletions proto/commonpb/page.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/commonpb/request-info.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions proto/commonpb/resource.pb.enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/commonpb/resource.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/commonpb/response.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions proto/errorpb/code.pb.enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/errorpb/code.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/errorpb/errors.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/errorpb/options.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/testcodepb/test.errors.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions proto/testcodepb/test.pb.enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b33bf5

Please sign in to comment.