mirror of
https://github.com/arkadiyt/protodump.git
synced 2026-10-21 01:36:52 +02:00
Merge pull request #8 from arkadiyt/atetelman--fix
Fix enum default values
This commit is contained in:
2 files changed
+4
-2
No files matched your search
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user