diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e814ea..8dbc57d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,14 +4,17 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.20' - name: Install Protoc run: | - sudo apt install -y protobuf-compiler + curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.1/protoc-28.1-linux-x86_64.zip + unzip protoc-28.1-linux-x86_64.zip -d $HOME/.local + export PATH="$PATH:$HOME/.local/bin" + protoc --version go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - name: Test run: make test diff --git a/go.mod b/go.mod index bcda4fc..4c3731f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/stretchr/testify v1.8.1 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.34.2 ) require ( diff --git a/go.sum b/go.sum index 1b2c304..75c0e0c 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -14,10 +12,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/protodump/fixtures/test.proto3 b/pkg/protodump/fixtures/test.proto3 index 255a253..f00ed10 100644 --- a/pkg/protodump/fixtures/test.proto3 +++ b/pkg/protodump/fixtures/test.proto3 @@ -34,6 +34,7 @@ message HelloRequest { .hello.world.HelloRequest.Test blah = 2; .hello.world.HelloRequest.NestedEnum blahblah = 3; .hello.world.HelloReply blaha = 4; + optional string version = 5; } message HelloReply { diff --git a/pkg/protodump/proto.go b/pkg/protodump/proto.go index 7336680..d9261ad 100644 --- a/pkg/protodump/proto.go +++ b/pkg/protodump/proto.go @@ -108,16 +108,20 @@ func (pd *ProtoDefinition) writeType(field protoreflect.FieldDescriptor) { func (pd *ProtoDefinition) writeOneof(oneof protoreflect.OneofDescriptor) { // TODO need to handle oneof options - pd.writeIndented("") - pd.write("oneof ") - pd.write(string(oneof.Name())) - pd.write(" {\n") - pd.indent() - for i := 0; i < oneof.Fields().Len(); i++ { - pd.writeField(oneof.Fields().Get(i)) + if oneof.IsSynthetic() { + pd.writeField(oneof.Fields().Get(0)) + } else { + pd.writeIndented("") + pd.write("oneof ") + pd.write(string(oneof.Name())) + pd.write(" {\n") + pd.indent() + for i := 0; i < oneof.Fields().Len(); i++ { + pd.writeField(oneof.Fields().Get(i)) + } + pd.dedent() + pd.writeIndented("}\n") } - pd.dedent() - pd.writeIndented("}\n") } func (pd *ProtoDefinition) writeField(field protoreflect.FieldDescriptor) {