Skip to content

Commit

Permalink
Merge pull request #8 from arkadiyt/atetelman--fix
Browse files Browse the repository at this point in the history
Fix enum default values
  • Loading branch information
arkadiyt authored May 24, 2024
2 parents 5a6bdfe + c60f553 commit 16270c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/protodump/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (pd *ProtoDefinition) writeField(field protoreflect.FieldDescriptor) {
if kind == "string" {
pd.write(fmt.Sprintf("\"%s\"", field.Default().String()))
} else if kind == "enum" {
pd.write(string(field.Enum().Values().ByNumber(field.Default().Enum()).Name()))
pd.write(string(field.DefaultEnumValue().Name()))
} else {
pd.write(field.Default().String())
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/protodump/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ func convertProtoToFileDescriptor(filePath string) (*descriptorpb.FileDescriptor
defer os.RemoveAll(dir)

filename := "proto.bin"
err = exec.Command("protoc", fmt.Sprintf("--go_out=%s", dir), fmt.Sprintf("--descriptor_set_out=%s", path.Join(dir, filename)), filePath).Run()
cmd := exec.Command("protoc", fmt.Sprintf("--go_out=%s", dir), fmt.Sprintf("--descriptor_set_out=%s", path.Join(dir, filename)), filePath)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Print(string(output))
return nil, err
}

Expand Down

0 comments on commit 16270c3

Please sign in to comment.