mirror of
https://github.com/arkadiyt/protodump.git
synced 2026-10-21 09:46: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" {
|
if kind == "string" {
|
||||||
pd.write(fmt.Sprintf("\"%s\"", field.Default().String()))
|
pd.write(fmt.Sprintf("\"%s\"", field.Default().String()))
|
||||||
} else if kind == "enum" {
|
} else if kind == "enum" {
|
||||||
pd.write(string(field.Enum().Values().ByNumber(field.Default().Enum()).Name()))
|
pd.write(string(field.DefaultEnumValue().Name()))
|
||||||
} else {
|
} else {
|
||||||
pd.write(field.Default().String())
|
pd.write(field.Default().String())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ func convertProtoToFileDescriptor(filePath string) (*descriptorpb.FileDescriptor
|
|||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
filename := "proto.bin"
|
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 {
|
if err != nil {
|
||||||
|
fmt.Print(string(output))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user