Skip to content

Commit

Permalink
*: use latest golang/protobuf version for library & code generator (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
glerchundi authored May 4, 2021
1 parent 8bc36ed commit faa4d12
Show file tree
Hide file tree
Showing 35 changed files with 48 additions and 76 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ testdata: testdata-graph testdata-go testdata/generated testdata/fdset.bin # gen

.PHONY: testdata-graph
testdata-graph: bin/protoc-gen-debug # parses the proto file sets in testdata/graph and renders binary CodeGeneratorRequest
set -e; for subdir in `find ./testdata/graph -type d -mindepth 1 -maxdepth 1`; do \
set -e; for subdir in `find ./testdata/graph -mindepth 1 -maxdepth 1 -type d`; do \
protoc -I ./testdata/graph \
--plugin=protoc-gen-debug=./bin/protoc-gen-debug \
--debug_out="$$subdir:$$subdir" \
Expand All @@ -49,15 +49,15 @@ testdata/generated: protoc-gen-go bin/protoc-gen-example
which protoc-gen-go || (go install github.com/golang/protobuf/protoc-gen-go)
rm -rf ./testdata/generated && mkdir -p ./testdata/generated
# generate the official go code, must be one directory at a time
set -e; for subdir in `find ./testdata/protos -type d -mindepth 1`; do \
files=`find $$subdir -name "*.proto" -maxdepth 1`; \
set -e; for subdir in `find ./testdata/protos -mindepth 1 -type d`; do \
files=`find $$subdir -maxdepth 1 -name "*.proto"`; \
[ ! -z "$$files" ] && \
protoc -I ./testdata/protos \
--go_out="$$GOPATH/src" \
$$files; \
done
# generate using our demo plugin, don't need to go directory at a time
set -e; for subdir in `find ./testdata/protos -type d -mindepth 1 -maxdepth 1`; do \
set -e; for subdir in `find ./testdata/protos -mindepth 1 -maxdepth 1 -type d`; do \
protoc -I ./testdata/protos \
--plugin=protoc-gen-example=./bin/protoc-gen-example \
--example_out="paths=source_relative:./testdata/generated" \
Expand All @@ -83,7 +83,7 @@ vendor: # install project dependencies

.PHONY: protoc-gen-go
protoc-gen-go:
which protoc-gen-go || (go get -u github.com/golang/protobuf/protoc-gen-go)
which protoc-gen-go || (go install github.com/golang/protobuf/protoc-gen-go)

bin/protoc-gen-example: # creates the demo protoc plugin for demonstrating uses of PG*
go build -o ./bin/protoc-gen-example ./testdata/protoc-gen-example
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/lyft/protoc-gen-star
go 1.14

require (
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.5.2
github.com/spf13/afero v1.3.3
github.com/stretchr/testify v1.6.1
)
26 changes: 8 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
Expand All @@ -31,13 +25,9 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
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.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
6 changes: 3 additions & 3 deletions lang/go/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: testdata-go-names
testdata-names: ../../bin/protoc-gen-debug # parse the proto file sets in testdata/names and renders binary CodeGeneratorRequest + official go codegen
cd testdata/names && \
set -e; for subdir in `find . -type d -mindepth 1 -maxdepth 1`; do \
set -e; for subdir in `find . -mindepth 1 -maxdepth 1 -type d`; do \
cd $$subdir; \
params=`cat params`; \
protoc -I . \
Expand All @@ -14,7 +14,7 @@ testdata-names: ../../bin/protoc-gen-debug # parse the proto file sets in testda

testdata-packages: ../../bin/protoc-gen-debug
cd testdata/packages && \
set -e; for subdir in `find . -type d -mindepth 1 -maxdepth 1 | grep -v targets`; do \
set -e; for subdir in `find . -mindepth 1 -maxdepth 1 -type d | grep -v targets`; do \
cd $$subdir; \
params=`cat params`; \
protoc -I . -I .. \
Expand All @@ -27,7 +27,7 @@ testdata-packages: ../../bin/protoc-gen-debug

testdata-outputs: ../../bin/protoc-gen-debug
cd testdata/outputs && \
set -e; for subdir in `find . -type d -mindepth 1 -maxdepth 1`; do \
set -e; for subdir in `find . -mindepth 1 -maxdepth 1 -type d`; do \
cd $$subdir; \
params=`cat params`; \
protoc -I . -I .. \
Expand Down
7 changes: 2 additions & 5 deletions lang/go/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func TestName(t *testing.T) {
ctx := loadContext(t, "names", "entities")

f := ast.Targets()["entities.proto"]
assert.Equal(t, pgs.Name("BAD_pack__age_name_"), ctx.Name(f))
assert.Equal(t, pgs.Name("BAD_pack__age_name_"), ctx.Name(f.Package()))
assert.Equal(t, pgs.Name("entities"), ctx.Name(f))
assert.Equal(t, pgs.Name("entities"), ctx.Name(f.Package()))

assert.Panics(t, func() {
ctx.Name(nil)
Expand All @@ -54,15 +54,12 @@ func TestName(t *testing.T) {
{"lower_snake_case", "LowerSnakeCase"},
{"lowercase", "Lowercase"},
{"UPPERCASE", "UPPERCASE"},
{"_underscore", "XUnderscore"},
{"__DoubleUnderscore", "X_DoubleUnderscore"},
{"String", "String"},
{"MsgWith3dInside", "MsgWith3DInside"},
{"MsgEndsWith3d", "MsgEndsWith3D"},

// Nested Messages
{"Nested.Message", "Nested_Message"},
{"Nested._underscore", "Nested_XUnderscore"},
{"Nested.String", "Nested_String"},
{"Nested.Message.Message", "Nested_Message_Message"},
{"Nested.lowerMsg", "NestedLowerMsg"},
Expand Down
4 changes: 0 additions & 4 deletions lang/go/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ func TestPackageName(t *testing.T) {
expected pgs.Name
}{
{"keyword", "_package"}, // go keywords are prefixed with _
{"none", "NO_pack__age_name_"}, // if there is no package or go_package option, use the input filepath
{"package", "my_package"}, // use the go_package option
{"unnamed", "names_unnamed"}, // use the proto package if no go_package
{"import", "bar"}, // uses the basename if go_package contains a /
{"override", "baz"}, // if go_package contains ;, use everything to the right
{"import_path", "_package"}, // import_path param used if no go_package option
{"mapped", "unaffected"}, // M mapped params are ignored for build targets
{"import_path_mapped", "go_package"}, // mixed import_path and M parameters should lose to go_package
{"transitive_package", "foobar"}, // go_option gets picked up from other files if present
{"digit", "_2019fizz"}, // digit at the start are prefixed with _
{"path_dash", "path_dash"}, // if basename of go_package contains invalid characters, replace with _
}

Expand Down
5 changes: 0 additions & 5 deletions lang/go/testdata/names/digit/digit.proto

This file was deleted.

Empty file.
8 changes: 1 addition & 7 deletions lang/go/testdata/names/entities/entities.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";

package names.entities;
option go_package = "BAD.pack--age.name$";
option go_package = "example.com/names/entities";

message UpperCamelCaseMessage {}

Expand All @@ -17,10 +17,6 @@ message lowercase {}

message UPPERCASE {}

message _underscore {}

message __DoubleUnderscore {}

message String {} // protected name

message Nested {
Expand All @@ -30,8 +26,6 @@ message Nested {
enum Enum { NESTED = 0; }
}

message _underscore {}

message String {} // protected name

enum Enum { VALUE = 0; }
Expand Down
4 changes: 0 additions & 4 deletions lang/go/testdata/names/import_path/import_path.proto

This file was deleted.

1 change: 0 additions & 1 deletion lang/go/testdata/names/import_path/params

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package names.import_path_mapped;
option go_package="go_package";
option go_package="github.com/fizz/buzz;go_package";

message Mapped {}
2 changes: 1 addition & 1 deletion lang/go/testdata/names/import_path_mapped/params
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Mimport_path_mapped.proto=github.com/foo/bar,import_path=github.com/fizz/buzz
Mimport_path_mapped.proto=github.com/foo/bar
2 changes: 1 addition & 1 deletion lang/go/testdata/names/keyword/keyword.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax="proto3";

package names.keyword;
option go_package = "package";
option go_package = "example.com/package";

message Package {}
2 changes: 1 addition & 1 deletion lang/go/testdata/names/mapped/mapped.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package names.mapped;
option go_package="unaffected";
option go_package="./;unaffected";

message Mapped {}
2 changes: 1 addition & 1 deletion lang/go/testdata/names/mapped/params
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Mmapped.proto=foobar
Mmapped.proto=example.com/foobar
3 changes: 0 additions & 3 deletions lang/go/testdata/names/none/NO.pack--age.name$.proto

This file was deleted.

Empty file removed lang/go/testdata/names/none/params
Empty file.
2 changes: 1 addition & 1 deletion lang/go/testdata/names/package/package.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax="proto3";

package names.package;
option go_package = "my_package";
option go_package = "example.com/names/package;my_package";

message Package {}
2 changes: 1 addition & 1 deletion lang/go/testdata/names/transitive_package/other.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax="proto3";
package names.transitive_package;

option go_package="foobar";
option go_package="example.com/names/foobar";

message Other {
bool value = 1;
Expand Down
2 changes: 2 additions & 0 deletions lang/go/testdata/names/transitive_package/transitive.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax="proto3";
package names.transitive_package;

option go_package="example.com/names/foobar";

message Transitive {
bool value = 1;
}
Empty file.
5 changes: 0 additions & 5 deletions lang/go/testdata/names/unnamed/unnamed.proto

This file was deleted.

2 changes: 1 addition & 1 deletion lang/go/testdata/outputs/mapped/mapped.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package outputs.mapped;
option go_package="unaffected";
option go_package="./;mapped";

message Mapped {}
2 changes: 1 addition & 1 deletion lang/go/testdata/outputs/mapped/params
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Mmapped.proto=foobar
Mmapped.proto=example.com/foobar
2 changes: 1 addition & 1 deletion lang/go/testdata/outputs/mapped_srcrel/mapped.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package outputs.mapped;
option go_package="unaffected";
option go_package="./;mapped";

message Mapped {}
2 changes: 1 addition & 1 deletion lang/go/testdata/outputs/mapped_srcrel/params
Original file line number Diff line number Diff line change
@@ -1 +1 @@
paths=source_relative,Mmapped.proto=foobar
paths=source_relative,Mmapped.proto=example.com/foobar
1 change: 1 addition & 0 deletions lang/go/testdata/outputs/none/none.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
syntax="proto3";
package outputs.none;
option go_package="./;none";
message None {}
2 changes: 2 additions & 0 deletions lang/go/testdata/outputs/none_srcrel/none.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
syntax="proto3";

option go_package="example.com/outputs/none";

message None {}
2 changes: 1 addition & 1 deletion lang/go/testdata/outputs/unqualified/unqualified.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package outputs.unqualified;
option go_package="unqualified";
option go_package="./;unqualified";

message Unqualified{}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package outputs.unqualified;
option go_package="unqualified";
option go_package="example.com/outputs/unqualified";

message Unqualified{}
2 changes: 1 addition & 1 deletion lang/go/testdata/packages/mapped/mapped.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax="proto3";
package packages.mapped;
option go_package="example.com/packages/mapped";
option go_package="./;mapped";

import "targets/fully_qualified/fully_qualified.proto";
import "targets/unqualified/unqualified.proto";
Expand Down
1 change: 1 addition & 0 deletions lang/go/testdata/packages/targets/none/none.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax="proto3";
package packages.targets.none;
option go_package="targets/none";

message None{}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package packages.targets.unqualified;
option go_package="unqualified";
option go_package="targets/unqualified";

message Unqualified{}
7 changes: 7 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build tools

package tools

import (
_ "github.com/golang/protobuf/protoc-gen-go"
)

0 comments on commit faa4d12

Please sign in to comment.