diff --git a/.gitignore b/.gitignore index bdf79c3..64e208a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ testdata/generated/ **/code_generator_request.pb.bin .idea/ .vscode/ +.work/ diff --git a/.travis.yml b/.travis.yml index 7ab01b8..b2a28a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ go_import_path: github.com/lyft/protoc-gen-star env: matrix: - - PROTOC_VER="3.5.1" - - PROTOC_VER="3.6.1" + - PROTOC_VER="3.11.4" + - PROTOC_VER="3.12.4" before_install: - mkdir -p $GOPATH/bin diff --git a/Makefile b/Makefile index 709fbd0..a614519 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,11 @@ bootstrap: testdata # set up the project for development .PHONY: lint lint: # lints the package for common code smells - set -e; for f in `find . -name "*.go" -not -name "*.pb.go"`; do \ + set -e; for f in `find . -name "*.go" -not -name "*.pb.go" | grep -v vendor`; do \ out=`gofmt -s -d $$f`; \ test -z "$$out" || (echo $$out && exit 1); \ done - which golint || go get -u golang.org/x/lint/golint - golint -set_exit_status ./... + go run golang.org/x/lint/golint -set_exit_status ./... go vet -all .PHONY: quick @@ -45,14 +44,14 @@ testdata-graph: bin/protoc-gen-debug # parses the proto file sets in testdata/gr `find $$subdir -name "*.proto"`; \ done -testdata/generated: protoc-gen-go bin/protoc-gen-example - which protoc-gen-go || (go install github.com/golang/protobuf/protoc-gen-go) +testdata/generated: bin/protoc-gen-go bin/protoc-gen-example 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`; \ [ ! -z "$$files" ] && \ protoc -I ./testdata/protos \ + --plugin=protoc-gen-go=./bin/protoc-gen-go \ --go_out="$$GOPATH/src" \ $$files; \ done @@ -71,28 +70,37 @@ testdata/fdset.bin: testdata/protos/**/*.proto .PHONY: testdata-go -testdata-go: protoc-gen-go bin/protoc-gen-debug # generate go-specific testdata +testdata-go: bin/protoc-gen-go bin/protoc-gen-debug # generate go-specific testdata cd lang/go && $(MAKE) \ testdata-names \ testdata-packages \ testdata-outputs -vendor: # install project dependencies - which glide || (curl https://glide.sh/get | sh) - glide install +vendor/github.com/gogo/protobuf/gogoproto/gogo.proto: go.mod go.sum + go mod vendor -.PHONY: protoc-gen-go -protoc-gen-go: - which protoc-gen-go || (go get -u github.com/golang/protobuf/protoc-gen-go) +WORKDIR := $(shell mkdir -p $(PWD)/.work && mktemp -d "$(PWD)/.work/tmp.XXX") + +.PHONY: gogoproto +gogoproto/gogo.pb.go: vendor/github.com/gogo/protobuf/gogoproto/gogo.proto bin/protoc-gen-go + @perl \ + -pe 's!(.*option[[:space:]]+.*go_package.*=.*"github.com/)gogo/protobuf(/gogoproto".*)!\1lyft/protoc-gen-star\2!' \ + $< > $(WORKDIR)/gogo.proto + @protoc -I$(WORKDIR) -I$(PWD)/vendor --plugin=protoc-gen-go=./bin/protoc-gen-go --go_out=$(WORKDIR) $(WORKDIR)/gogo.proto + @mv $(WORKDIR)/github.com/lyft/protoc-gen-star/gogoproto/gogo.pb.go $@ + +bin/protoc-gen-go: # creates the protoc-gen-go plugin using the vendored version + go build -o $@ 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 + go build -o $@ ./testdata/protoc-gen-example bin/protoc-gen-debug: # creates the protoc-gen-debug protoc plugin for output ProtoGeneratorRequest messages - go build -o ./bin/protoc-gen-debug ./protoc-gen-debug + go build -o $@ ./protoc-gen-debug .PHONY: clean clean: + rm -rf .work rm -rf vendor rm -rf bin rm -rf testdata/generated diff --git a/README.md b/README.md index c33c2ac..20848ac 100644 --- a/README.md +++ b/README.md @@ -300,16 +300,13 @@ PG* seeks to provide all the tools necessary to rapidly and ergonomically extend ### Setup -For developing on PG*, you should install the package within the `GOPATH`. PG* uses [glide][glide] for dependency management. +For developing on PG*, you should install the package within the `GOPATH`. ```sh go get -u github.com/lyft/protoc-gen-star cd $GOPATH/src/github.com/lyft/protoc-gen-star -make vendor ``` -To upgrade dependencies, please make the necessary modifications in `glide.yaml` and run `glide update`. - ### Linting & Static Analysis To avoid style nits and also to enforce some best practices for Go packages, PG* requires passing `golint`, `go vet`, and `go fmt -s` for all code changes. @@ -364,7 +361,6 @@ make testdata/generated PG* uses [TravisCI][travis] to validate all code changes. Please view the [configuration][travis.yml] for what tests are involved in the validation. -[glide]: http://glide.sh [pgg]: https://github.com/golang/protobuf/tree/master/protoc-gen-go [pge]: https://github.com/lyft/protoc-gen-star/tree/master/testdata/protoc-gen-example [travis]: https://travis-ci.com/lyft/protoc-gen-star diff --git a/go.mod b/go.mod index c185fcc..5a8f8d3 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,12 @@ module github.com/lyft/protoc-gen-star go 1.14 require ( - github.com/golang/protobuf v1.4.2 + github.com/gogo/protobuf v1.3.1 + github.com/golang/protobuf v1.3.5 github.com/spf13/afero v1.3.3 github.com/stretchr/testify v1.6.1 + golang.org/x/lint v0.0.0-20200302205851-738671d3881b + golang.org/x/text v0.3.3 // indirect + golang.org/x/tools v0.0.0-20200806234136-990129eca547 + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index a0ec335..92264cc 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,11 @@ 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/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 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= @@ -22,22 +17,40 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200806234136-990129eca547 h1:HjPd370wmFEFsBBdDEikoje9tDY3OHE7UB2erLJBmss= +golang.org/x/tools v0.0.0-20200806234136-990129eca547/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 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= diff --git a/gogoproto/gogo.pb.go b/gogoproto/gogo.pb.go new file mode 100644 index 0000000..006d4ad --- /dev/null +++ b/gogoproto/gogo.pb.go @@ -0,0 +1,875 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: gogo.proto + +package gogoproto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +var E_GoprotoEnumPrefix = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 62001, + Name: "gogoproto.goproto_enum_prefix", + Tag: "varint,62001,opt,name=goproto_enum_prefix", + Filename: "gogo.proto", +} + +var E_GoprotoEnumStringer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 62021, + Name: "gogoproto.goproto_enum_stringer", + Tag: "varint,62021,opt,name=goproto_enum_stringer", + Filename: "gogo.proto", +} + +var E_EnumStringer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 62022, + Name: "gogoproto.enum_stringer", + Tag: "varint,62022,opt,name=enum_stringer", + Filename: "gogo.proto", +} + +var E_EnumCustomname = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumOptions)(nil), + ExtensionType: (*string)(nil), + Field: 62023, + Name: "gogoproto.enum_customname", + Tag: "bytes,62023,opt,name=enum_customname", + Filename: "gogo.proto", +} + +var E_Enumdecl = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 62024, + Name: "gogoproto.enumdecl", + Tag: "varint,62024,opt,name=enumdecl", + Filename: "gogo.proto", +} + +var E_EnumvalueCustomname = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.EnumValueOptions)(nil), + ExtensionType: (*string)(nil), + Field: 66001, + Name: "gogoproto.enumvalue_customname", + Tag: "bytes,66001,opt,name=enumvalue_customname", + Filename: "gogo.proto", +} + +var E_GoprotoGettersAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63001, + Name: "gogoproto.goproto_getters_all", + Tag: "varint,63001,opt,name=goproto_getters_all", + Filename: "gogo.proto", +} + +var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63002, + Name: "gogoproto.goproto_enum_prefix_all", + Tag: "varint,63002,opt,name=goproto_enum_prefix_all", + Filename: "gogo.proto", +} + +var E_GoprotoStringerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63003, + Name: "gogoproto.goproto_stringer_all", + Tag: "varint,63003,opt,name=goproto_stringer_all", + Filename: "gogo.proto", +} + +var E_VerboseEqualAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63004, + Name: "gogoproto.verbose_equal_all", + Tag: "varint,63004,opt,name=verbose_equal_all", + Filename: "gogo.proto", +} + +var E_FaceAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63005, + Name: "gogoproto.face_all", + Tag: "varint,63005,opt,name=face_all", + Filename: "gogo.proto", +} + +var E_GostringAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63006, + Name: "gogoproto.gostring_all", + Tag: "varint,63006,opt,name=gostring_all", + Filename: "gogo.proto", +} + +var E_PopulateAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63007, + Name: "gogoproto.populate_all", + Tag: "varint,63007,opt,name=populate_all", + Filename: "gogo.proto", +} + +var E_StringerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63008, + Name: "gogoproto.stringer_all", + Tag: "varint,63008,opt,name=stringer_all", + Filename: "gogo.proto", +} + +var E_OnlyoneAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63009, + Name: "gogoproto.onlyone_all", + Tag: "varint,63009,opt,name=onlyone_all", + Filename: "gogo.proto", +} + +var E_EqualAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63013, + Name: "gogoproto.equal_all", + Tag: "varint,63013,opt,name=equal_all", + Filename: "gogo.proto", +} + +var E_DescriptionAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63014, + Name: "gogoproto.description_all", + Tag: "varint,63014,opt,name=description_all", + Filename: "gogo.proto", +} + +var E_TestgenAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63015, + Name: "gogoproto.testgen_all", + Tag: "varint,63015,opt,name=testgen_all", + Filename: "gogo.proto", +} + +var E_BenchgenAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63016, + Name: "gogoproto.benchgen_all", + Tag: "varint,63016,opt,name=benchgen_all", + Filename: "gogo.proto", +} + +var E_MarshalerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63017, + Name: "gogoproto.marshaler_all", + Tag: "varint,63017,opt,name=marshaler_all", + Filename: "gogo.proto", +} + +var E_UnmarshalerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63018, + Name: "gogoproto.unmarshaler_all", + Tag: "varint,63018,opt,name=unmarshaler_all", + Filename: "gogo.proto", +} + +var E_StableMarshalerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63019, + Name: "gogoproto.stable_marshaler_all", + Tag: "varint,63019,opt,name=stable_marshaler_all", + Filename: "gogo.proto", +} + +var E_SizerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63020, + Name: "gogoproto.sizer_all", + Tag: "varint,63020,opt,name=sizer_all", + Filename: "gogo.proto", +} + +var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63021, + Name: "gogoproto.goproto_enum_stringer_all", + Tag: "varint,63021,opt,name=goproto_enum_stringer_all", + Filename: "gogo.proto", +} + +var E_EnumStringerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63022, + Name: "gogoproto.enum_stringer_all", + Tag: "varint,63022,opt,name=enum_stringer_all", + Filename: "gogo.proto", +} + +var E_UnsafeMarshalerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63023, + Name: "gogoproto.unsafe_marshaler_all", + Tag: "varint,63023,opt,name=unsafe_marshaler_all", + Filename: "gogo.proto", +} + +var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63024, + Name: "gogoproto.unsafe_unmarshaler_all", + Tag: "varint,63024,opt,name=unsafe_unmarshaler_all", + Filename: "gogo.proto", +} + +var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63025, + Name: "gogoproto.goproto_extensions_map_all", + Tag: "varint,63025,opt,name=goproto_extensions_map_all", + Filename: "gogo.proto", +} + +var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63026, + Name: "gogoproto.goproto_unrecognized_all", + Tag: "varint,63026,opt,name=goproto_unrecognized_all", + Filename: "gogo.proto", +} + +var E_GogoprotoImport = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63027, + Name: "gogoproto.gogoproto_import", + Tag: "varint,63027,opt,name=gogoproto_import", + Filename: "gogo.proto", +} + +var E_ProtosizerAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63028, + Name: "gogoproto.protosizer_all", + Tag: "varint,63028,opt,name=protosizer_all", + Filename: "gogo.proto", +} + +var E_CompareAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63029, + Name: "gogoproto.compare_all", + Tag: "varint,63029,opt,name=compare_all", + Filename: "gogo.proto", +} + +var E_TypedeclAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63030, + Name: "gogoproto.typedecl_all", + Tag: "varint,63030,opt,name=typedecl_all", + Filename: "gogo.proto", +} + +var E_EnumdeclAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63031, + Name: "gogoproto.enumdecl_all", + Tag: "varint,63031,opt,name=enumdecl_all", + Filename: "gogo.proto", +} + +var E_GoprotoRegistration = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63032, + Name: "gogoproto.goproto_registration", + Tag: "varint,63032,opt,name=goproto_registration", + Filename: "gogo.proto", +} + +var E_MessagenameAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63033, + Name: "gogoproto.messagename_all", + Tag: "varint,63033,opt,name=messagename_all", + Filename: "gogo.proto", +} + +var E_GoprotoSizecacheAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63034, + Name: "gogoproto.goproto_sizecache_all", + Tag: "varint,63034,opt,name=goproto_sizecache_all", + Filename: "gogo.proto", +} + +var E_GoprotoUnkeyedAll = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FileOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 63035, + Name: "gogoproto.goproto_unkeyed_all", + Tag: "varint,63035,opt,name=goproto_unkeyed_all", + Filename: "gogo.proto", +} + +var E_GoprotoGetters = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64001, + Name: "gogoproto.goproto_getters", + Tag: "varint,64001,opt,name=goproto_getters", + Filename: "gogo.proto", +} + +var E_GoprotoStringer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64003, + Name: "gogoproto.goproto_stringer", + Tag: "varint,64003,opt,name=goproto_stringer", + Filename: "gogo.proto", +} + +var E_VerboseEqual = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64004, + Name: "gogoproto.verbose_equal", + Tag: "varint,64004,opt,name=verbose_equal", + Filename: "gogo.proto", +} + +var E_Face = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64005, + Name: "gogoproto.face", + Tag: "varint,64005,opt,name=face", + Filename: "gogo.proto", +} + +var E_Gostring = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64006, + Name: "gogoproto.gostring", + Tag: "varint,64006,opt,name=gostring", + Filename: "gogo.proto", +} + +var E_Populate = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64007, + Name: "gogoproto.populate", + Tag: "varint,64007,opt,name=populate", + Filename: "gogo.proto", +} + +var E_Stringer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 67008, + Name: "gogoproto.stringer", + Tag: "varint,67008,opt,name=stringer", + Filename: "gogo.proto", +} + +var E_Onlyone = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64009, + Name: "gogoproto.onlyone", + Tag: "varint,64009,opt,name=onlyone", + Filename: "gogo.proto", +} + +var E_Equal = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64013, + Name: "gogoproto.equal", + Tag: "varint,64013,opt,name=equal", + Filename: "gogo.proto", +} + +var E_Description = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64014, + Name: "gogoproto.description", + Tag: "varint,64014,opt,name=description", + Filename: "gogo.proto", +} + +var E_Testgen = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64015, + Name: "gogoproto.testgen", + Tag: "varint,64015,opt,name=testgen", + Filename: "gogo.proto", +} + +var E_Benchgen = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64016, + Name: "gogoproto.benchgen", + Tag: "varint,64016,opt,name=benchgen", + Filename: "gogo.proto", +} + +var E_Marshaler = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64017, + Name: "gogoproto.marshaler", + Tag: "varint,64017,opt,name=marshaler", + Filename: "gogo.proto", +} + +var E_Unmarshaler = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64018, + Name: "gogoproto.unmarshaler", + Tag: "varint,64018,opt,name=unmarshaler", + Filename: "gogo.proto", +} + +var E_StableMarshaler = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64019, + Name: "gogoproto.stable_marshaler", + Tag: "varint,64019,opt,name=stable_marshaler", + Filename: "gogo.proto", +} + +var E_Sizer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64020, + Name: "gogoproto.sizer", + Tag: "varint,64020,opt,name=sizer", + Filename: "gogo.proto", +} + +var E_UnsafeMarshaler = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64023, + Name: "gogoproto.unsafe_marshaler", + Tag: "varint,64023,opt,name=unsafe_marshaler", + Filename: "gogo.proto", +} + +var E_UnsafeUnmarshaler = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64024, + Name: "gogoproto.unsafe_unmarshaler", + Tag: "varint,64024,opt,name=unsafe_unmarshaler", + Filename: "gogo.proto", +} + +var E_GoprotoExtensionsMap = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64025, + Name: "gogoproto.goproto_extensions_map", + Tag: "varint,64025,opt,name=goproto_extensions_map", + Filename: "gogo.proto", +} + +var E_GoprotoUnrecognized = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64026, + Name: "gogoproto.goproto_unrecognized", + Tag: "varint,64026,opt,name=goproto_unrecognized", + Filename: "gogo.proto", +} + +var E_Protosizer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64028, + Name: "gogoproto.protosizer", + Tag: "varint,64028,opt,name=protosizer", + Filename: "gogo.proto", +} + +var E_Compare = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64029, + Name: "gogoproto.compare", + Tag: "varint,64029,opt,name=compare", + Filename: "gogo.proto", +} + +var E_Typedecl = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64030, + Name: "gogoproto.typedecl", + Tag: "varint,64030,opt,name=typedecl", + Filename: "gogo.proto", +} + +var E_Messagename = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64033, + Name: "gogoproto.messagename", + Tag: "varint,64033,opt,name=messagename", + Filename: "gogo.proto", +} + +var E_GoprotoSizecache = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64034, + Name: "gogoproto.goproto_sizecache", + Tag: "varint,64034,opt,name=goproto_sizecache", + Filename: "gogo.proto", +} + +var E_GoprotoUnkeyed = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.MessageOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 64035, + Name: "gogoproto.goproto_unkeyed", + Tag: "varint,64035,opt,name=goproto_unkeyed", + Filename: "gogo.proto", +} + +var E_Nullable = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 65001, + Name: "gogoproto.nullable", + Tag: "varint,65001,opt,name=nullable", + Filename: "gogo.proto", +} + +var E_Embed = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 65002, + Name: "gogoproto.embed", + Tag: "varint,65002,opt,name=embed", + Filename: "gogo.proto", +} + +var E_Customtype = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65003, + Name: "gogoproto.customtype", + Tag: "bytes,65003,opt,name=customtype", + Filename: "gogo.proto", +} + +var E_Customname = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65004, + Name: "gogoproto.customname", + Tag: "bytes,65004,opt,name=customname", + Filename: "gogo.proto", +} + +var E_Jsontag = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65005, + Name: "gogoproto.jsontag", + Tag: "bytes,65005,opt,name=jsontag", + Filename: "gogo.proto", +} + +var E_Moretags = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65006, + Name: "gogoproto.moretags", + Tag: "bytes,65006,opt,name=moretags", + Filename: "gogo.proto", +} + +var E_Casttype = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65007, + Name: "gogoproto.casttype", + Tag: "bytes,65007,opt,name=casttype", + Filename: "gogo.proto", +} + +var E_Castkey = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65008, + Name: "gogoproto.castkey", + Tag: "bytes,65008,opt,name=castkey", + Filename: "gogo.proto", +} + +var E_Castvalue = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 65009, + Name: "gogoproto.castvalue", + Tag: "bytes,65009,opt,name=castvalue", + Filename: "gogo.proto", +} + +var E_Stdtime = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 65010, + Name: "gogoproto.stdtime", + Tag: "varint,65010,opt,name=stdtime", + Filename: "gogo.proto", +} + +var E_Stdduration = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 65011, + Name: "gogoproto.stdduration", + Tag: "varint,65011,opt,name=stdduration", + Filename: "gogo.proto", +} + +var E_Wktpointer = &proto.ExtensionDesc{ + ExtendedType: (*descriptor.FieldOptions)(nil), + ExtensionType: (*bool)(nil), + Field: 65012, + Name: "gogoproto.wktpointer", + Tag: "varint,65012,opt,name=wktpointer", + Filename: "gogo.proto", +} + +func init() { + proto.RegisterExtension(E_GoprotoEnumPrefix) + proto.RegisterExtension(E_GoprotoEnumStringer) + proto.RegisterExtension(E_EnumStringer) + proto.RegisterExtension(E_EnumCustomname) + proto.RegisterExtension(E_Enumdecl) + proto.RegisterExtension(E_EnumvalueCustomname) + proto.RegisterExtension(E_GoprotoGettersAll) + proto.RegisterExtension(E_GoprotoEnumPrefixAll) + proto.RegisterExtension(E_GoprotoStringerAll) + proto.RegisterExtension(E_VerboseEqualAll) + proto.RegisterExtension(E_FaceAll) + proto.RegisterExtension(E_GostringAll) + proto.RegisterExtension(E_PopulateAll) + proto.RegisterExtension(E_StringerAll) + proto.RegisterExtension(E_OnlyoneAll) + proto.RegisterExtension(E_EqualAll) + proto.RegisterExtension(E_DescriptionAll) + proto.RegisterExtension(E_TestgenAll) + proto.RegisterExtension(E_BenchgenAll) + proto.RegisterExtension(E_MarshalerAll) + proto.RegisterExtension(E_UnmarshalerAll) + proto.RegisterExtension(E_StableMarshalerAll) + proto.RegisterExtension(E_SizerAll) + proto.RegisterExtension(E_GoprotoEnumStringerAll) + proto.RegisterExtension(E_EnumStringerAll) + proto.RegisterExtension(E_UnsafeMarshalerAll) + proto.RegisterExtension(E_UnsafeUnmarshalerAll) + proto.RegisterExtension(E_GoprotoExtensionsMapAll) + proto.RegisterExtension(E_GoprotoUnrecognizedAll) + proto.RegisterExtension(E_GogoprotoImport) + proto.RegisterExtension(E_ProtosizerAll) + proto.RegisterExtension(E_CompareAll) + proto.RegisterExtension(E_TypedeclAll) + proto.RegisterExtension(E_EnumdeclAll) + proto.RegisterExtension(E_GoprotoRegistration) + proto.RegisterExtension(E_MessagenameAll) + proto.RegisterExtension(E_GoprotoSizecacheAll) + proto.RegisterExtension(E_GoprotoUnkeyedAll) + proto.RegisterExtension(E_GoprotoGetters) + proto.RegisterExtension(E_GoprotoStringer) + proto.RegisterExtension(E_VerboseEqual) + proto.RegisterExtension(E_Face) + proto.RegisterExtension(E_Gostring) + proto.RegisterExtension(E_Populate) + proto.RegisterExtension(E_Stringer) + proto.RegisterExtension(E_Onlyone) + proto.RegisterExtension(E_Equal) + proto.RegisterExtension(E_Description) + proto.RegisterExtension(E_Testgen) + proto.RegisterExtension(E_Benchgen) + proto.RegisterExtension(E_Marshaler) + proto.RegisterExtension(E_Unmarshaler) + proto.RegisterExtension(E_StableMarshaler) + proto.RegisterExtension(E_Sizer) + proto.RegisterExtension(E_UnsafeMarshaler) + proto.RegisterExtension(E_UnsafeUnmarshaler) + proto.RegisterExtension(E_GoprotoExtensionsMap) + proto.RegisterExtension(E_GoprotoUnrecognized) + proto.RegisterExtension(E_Protosizer) + proto.RegisterExtension(E_Compare) + proto.RegisterExtension(E_Typedecl) + proto.RegisterExtension(E_Messagename) + proto.RegisterExtension(E_GoprotoSizecache) + proto.RegisterExtension(E_GoprotoUnkeyed) + proto.RegisterExtension(E_Nullable) + proto.RegisterExtension(E_Embed) + proto.RegisterExtension(E_Customtype) + proto.RegisterExtension(E_Customname) + proto.RegisterExtension(E_Jsontag) + proto.RegisterExtension(E_Moretags) + proto.RegisterExtension(E_Casttype) + proto.RegisterExtension(E_Castkey) + proto.RegisterExtension(E_Castvalue) + proto.RegisterExtension(E_Stdtime) + proto.RegisterExtension(E_Stdduration) + proto.RegisterExtension(E_Wktpointer) +} + +func init() { proto.RegisterFile("gogo.proto", fileDescriptor_592445b5231bc2b9) } + +var fileDescriptor_592445b5231bc2b9 = []byte{ + // 1340 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0xc9, 0x6f, 0x1c, 0x45, + 0x17, 0xc0, 0xf5, 0xe9, 0x4b, 0x14, 0x4f, 0x79, 0x8b, 0xc7, 0xc6, 0x84, 0x08, 0x44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ad, 0x66, 0xcd, 0x09, 0x57, 0x86, 0x93, 0xc1, 0xfa, 0x8a, 0x2a, + 0x5e, 0xa8, 0xba, 0xfb, 0x3d, 0x11, 0xed, 0x4f, 0x95, 0x93, 0x4c, 0x96, 0x3f, 0x47, 0xfe, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0x0f, 0x23, 0xd4, 0x34, 0x8a, 0x15, 0x00, 0x00, +} diff --git a/lang/go/Makefile b/lang/go/Makefile index a4dac5c..e8a4c46 100644 --- a/lang/go/Makefile +++ b/lang/go/Makefile @@ -1,5 +1,5 @@ .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 +testdata-names: ../../bin/protoc-gen-debug ../../bin/protoc-gen-go # 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 \ cd $$subdir; \ @@ -7,12 +7,13 @@ testdata-names: ../../bin/protoc-gen-debug # parse the proto file sets in testda protoc -I . \ --plugin=protoc-gen-debug=../../../../../bin/protoc-gen-debug \ --debug_out=".:." \ + --plugin=protoc-gen-go=../../../../../bin/protoc-gen-go \ --go_out="plugins,paths=source_relative,$$params:." \ `find . -name "*.proto"`; \ cd -; \ done -testdata-packages: ../../bin/protoc-gen-debug +testdata-packages: ../../bin/protoc-gen-debug ../../bin/protoc-gen-go cd testdata/packages && \ set -e; for subdir in `find . -type d -mindepth 1 -maxdepth 1 | grep -v targets`; do \ cd $$subdir; \ @@ -20,12 +21,13 @@ testdata-packages: ../../bin/protoc-gen-debug protoc -I . -I .. \ --plugin=protoc-gen-debug=../../../../../bin/protoc-gen-debug \ --debug_out=".:." \ + --plugin=protoc-gen-go=../../../../../bin/protoc-gen-go \ --go_out="paths=source_relative,$$params:." \ `find . -name "*.proto"`; \ cd -; \ done -testdata-outputs: ../../bin/protoc-gen-debug +testdata-outputs: ../../bin/protoc-gen-debug ../../bin/protoc-gen-go cd testdata/outputs && \ set -e; for subdir in `find . -type d -mindepth 1 -maxdepth 1`; do \ cd $$subdir; \ @@ -33,6 +35,7 @@ testdata-outputs: ../../bin/protoc-gen-debug protoc -I . -I .. \ --plugin=protoc-gen-debug=../../../../../bin/protoc-gen-debug \ --debug_out=".:." \ + --plugin=protoc-gen-go=../../../../../bin/protoc-gen-go \ --go_out="$$params:." \ `find . -name "*.proto"`; \ cd -; \ @@ -40,3 +43,6 @@ testdata-outputs: ../../bin/protoc-gen-debug ../../bin/protoc-gen-debug: cd ../.. && $(MAKE) bin/protoc-gen-debug + +../../bin/protoc-gen-go: + cd ../.. && $(MAKE) bin/protoc-gen-go diff --git a/lang/go/context.go b/lang/go/context.go index 86d06f4..e39410d 100644 --- a/lang/go/context.go +++ b/lang/go/context.go @@ -60,6 +60,16 @@ type Context interface { // OutputPath returns the output path relative to the plugin's output destination OutputPath(entity pgs.Entity) pgs.FilePath + + // FieldTypeImportPath returns name of the Field type's package as it would appear in + // Go source generated by the official protoc-gen-go plugin. + // For builtin types empty FieldPath will be returned. + FieldTypePackageName(field pgs.Field) pgs.Name + + // FieldTypeImportPath returns the Go import path of the type of the Field + // as it would be included in an import block in a Go file. + // For builtin types empty FieldPath will be returned. + FieldTypeImportPath(field pgs.Field) pgs.FilePath } type context struct{ p pgs.Parameters } @@ -71,3 +81,11 @@ func InitContext(params pgs.Parameters) Context { } func (c context) Params() pgs.Parameters { return c.p } + +type gogoContext struct{ context } + +// InitGoGoContext configures a GoGo Context that should be used for deriving GoGo names +// for all Packages and Entities. +func InitGoGoContext(params pgs.Parameters) Context { + return gogoContext{context{params}} +} diff --git a/lang/go/name.go b/lang/go/name.go index d31a965..db980ee 100644 --- a/lang/go/name.go +++ b/lang/go/name.go @@ -6,6 +6,7 @@ import ( "unicode/utf8" pgs "github.com/lyft/protoc-gen-star" + "github.com/lyft/protoc-gen-star/gogoproto" ) func (c context) Name(node pgs.Node) pgs.Name { @@ -43,16 +44,58 @@ func (c context) Name(node pgs.Node) pgs.Name { } } -func (c context) OneofOption(field pgs.Field) pgs.Name { - n := pgs.Name(joinNames(c.Name(field.Message()), c.Name(field))) +func (c gogoContext) Name(node pgs.Node) pgs.Name { + switch en := node.(type) { + case pgs.Field: + var embed bool + ok, err := en.Extension(gogoproto.E_Embed, &embed) + if err != nil { + panic(fmt.Errorf("failed to parse embed extension value: %s", err)) + } + if ok && embed { + return "" + } - for _, msg := range field.Message().Messages() { + var customname string + ok, err = en.Extension(gogoproto.E_Customname, &customname) + if err != nil { + panic(fmt.Errorf("failed to parse customname extension value: %s", err)) + } + if ok { + return pgs.Name(customname) + } + case pgs.Enum: + var customname string + ok, err := en.Extension(gogoproto.E_EnumCustomname, &customname) + if err != nil { + panic(fmt.Errorf("failed to parse enum_customname extension value: %s", err)) + } + if ok { + return pgs.Name(customname) + } + case pgs.EnumValue: + var customname string + ok, err := en.Extension(gogoproto.E_EnumvalueCustomname, &customname) + if err != nil { + panic(fmt.Errorf("failed to parse enumvalue_customname extension value: %s", err)) + } + if ok { + return pgs.Name(customname) + } + } + return c.context.Name(node) +} + +func oneofOption(c Context, f pgs.Field) pgs.Name { + n := pgs.Name(joinNames(c.Name(f.Message()), c.Name(f))) + + for _, msg := range f.Message().Messages() { if c.Name(msg) == n { return n + "_" } } - for _, en := range field.Message().Enums() { + for _, en := range f.Message().Enums() { if c.Name(en) == n { return n + "_" } @@ -61,6 +104,14 @@ func (c context) OneofOption(field pgs.Field) pgs.Name { return n } +func (c context) OneofOption(field pgs.Field) pgs.Name { + return oneofOption(c, field) +} + +func (c gogoContext) OneofOption(field pgs.Field) pgs.Name { + return oneofOption(c, field) +} + func (c context) ServerName(s pgs.Service) pgs.Name { n := PGGUpperCamelCase(s.Name()) return pgs.Name(fmt.Sprintf("%sServer", n)) diff --git a/lang/go/package.go b/lang/go/package.go index 0597a7e..1653856 100644 --- a/lang/go/package.go +++ b/lang/go/package.go @@ -1,6 +1,7 @@ package pgsgo import ( + "fmt" "go/token" "regexp" "strings" @@ -8,10 +9,75 @@ import ( "unicode/utf8" pgs "github.com/lyft/protoc-gen-star" + "github.com/lyft/protoc-gen-star/gogoproto" ) var nonAlphaNumPattern = regexp.MustCompile("[^a-zA-Z0-9]") +func gogoType(f pgs.Field) (pgs.FilePath, TypeName, bool) { + ft := f.Type() + switch { + case ft.IsMap(): + return "", "", false + case ft.IsRepeated(): + return "", "", false + case ft.IsEnum(): + return "", "", false + case ft.IsEmbed(): + em := ft.Embed() + if em.IsWellKnown() { + switch em.WellKnownType() { + case pgs.TimestampWKT: + var stdtime bool + ok, err := f.Extension(gogoproto.E_Stdtime, &stdtime) + if err != nil { + panic(fmt.Errorf("failed to parse stdtime extension value: %s", err)) + } + if ok && stdtime { + return pgs.FilePath("time"), TypeName("time.Time"), true + } + + case pgs.DurationWKT: + var stdduration bool + ok, err := f.Extension(gogoproto.E_Stdduration, &stdduration) + if err != nil { + panic(fmt.Errorf("failed to parse stdduration extension value: %s", err)) + } + if ok && stdduration { + return pgs.FilePath("time"), TypeName("time.Duration"), true + } + } + } + } + + var customtype string + hasCustomType, err := f.Extension(gogoproto.E_Customtype, &customtype) + if err != nil { + panic(fmt.Errorf("failed to parse customtype extension value: %s", err)) + } + var casttype string + hasCastType, err := f.Extension(gogoproto.E_Casttype, &casttype) + if err != nil { + panic(fmt.Errorf("failed to parse casttype extension value: %s", err)) + } + if hasCustomType && hasCastType { + panic(fmt.Errorf("both casttype and customtype specifed")) + } + if !hasCustomType && !hasCastType { + return "", "", false + } + + typeName := customtype + if hasCastType { + typeName = casttype + } + if i := strings.LastIndex(typeName, "."); i > 0 { + pkg := typeName[:i] + return pgs.FilePath(pkg), TypeName(fmt.Sprintf("%s.%s", nonAlphaNumPattern.ReplaceAllString(pkg, "_"), typeName[i+1:])), true + } + return "", TypeName(typeName), true +} + func (c context) PackageName(node pgs.Node) pgs.Name { e, ok := node.(pgs.Entity) if !ok { @@ -40,12 +106,70 @@ func (c context) PackageName(node pgs.Node) pgs.Name { return pgs.Name(pkg) } +func (c context) FieldTypePackageName(f pgs.Field) pgs.Name { + var en pgs.Entity + switch ft := f.Type(); { + case ft.IsEmbed(): + en = ft.Embed() + case ft.IsEnum(): + en = ft.Enum() + case ft.IsRepeated(), ft.IsMap(): + el := ft.Element() + switch { + case el.IsEmbed(): + en = el.Embed() + case el.IsEnum(): + en = el.Enum() + } + default: + return pgs.Name("") + } + return c.PackageName(en) +} + +func (c gogoContext) FieldTypePackageName(f pgs.Field) pgs.Name { + pkg, _, ok := gogoType(f) + if !ok { + return c.context.FieldTypePackageName(f) + } + return pgs.Name(nonAlphaNumPattern.ReplaceAllString(string(pkg), "_")) +} + func (c context) ImportPath(e pgs.Entity) pgs.FilePath { path, _ := c.optionPackage(e) path = c.p.Str("import_prefix") + path return pgs.FilePath(path) } +func (c context) FieldTypeImportPath(f pgs.Field) pgs.FilePath { + var en pgs.Entity + switch ft := f.Type(); { + case ft.IsEmbed(): + en = ft.Embed() + case ft.IsEnum(): + en = ft.Enum() + case ft.IsRepeated(), ft.IsMap(): + el := ft.Element() + switch { + case el.IsEmbed(): + en = el.Embed() + case el.IsEnum(): + en = el.Enum() + } + default: + return pgs.FilePath("") + } + return c.ImportPath(en) +} + +func (c gogoContext) FieldTypeImportPath(f pgs.Field) pgs.FilePath { + pkg, _, ok := gogoType(f) + if !ok { + return c.context.FieldTypeImportPath(f) + } + return pkg +} + func (c context) OutputPath(e pgs.Entity) pgs.FilePath { out := e.File().InputPath().SetExt(".pb.go") diff --git a/lang/go/type_name.go b/lang/go/type_name.go index 9f24821..bb30eec 100644 --- a/lang/go/type_name.go +++ b/lang/go/type_name.go @@ -5,22 +5,23 @@ import ( "strings" pgs "github.com/lyft/protoc-gen-star" + "github.com/lyft/protoc-gen-star/gogoproto" ) -func (c context) Type(f pgs.Field) TypeName { +func fieldTypeName(c Context, f pgs.Field) TypeName { ft := f.Type() var t TypeName switch { case ft.IsMap(): key := scalarType(ft.Key().ProtoType()) - return TypeName(fmt.Sprintf("map[%s]%s", key, c.elType(ft))) + return TypeName(fmt.Sprintf("map[%s]%s", key, elType(c, ft))) case ft.IsRepeated(): - return TypeName(fmt.Sprintf("[]%s", c.elType(ft))) + return TypeName(fmt.Sprintf("[]%s", elType(c, ft))) case ft.IsEmbed(): - return c.importableTypeName(f, ft.Embed()).Pointer() + return importableTypeName(c, f, ft.Embed()).Pointer() case ft.IsEnum(): - t = c.importableTypeName(f, ft.Enum()) + t = importableTypeName(c, f, ft.Enum()) default: t = scalarType(ft.ProtoType()) } @@ -32,7 +33,37 @@ func (c context) Type(f pgs.Field) TypeName { return t } -func (c context) importableTypeName(f pgs.Field, e pgs.Entity) TypeName { +func (c context) Type(f pgs.Field) TypeName { + return fieldTypeName(c, f) +} + +func (c gogoContext) Type(f pgs.Field) (t TypeName) { + _, name, hasGoGoType := gogoType(f) + if !hasGoGoType { + name = fieldTypeName(c, f) + } + + ft := f.Type() + switch { + case ft.IsMap(), ft.IsRepeated(), ft.IsEnum(): + return name + + case ft.IsEmbed(), hasGoGoType: + var nullable bool + ok, err := f.Extension(gogoproto.E_Nullable, &nullable) + if err != nil { + panic(fmt.Errorf("failed to parse nullable extension value: %s", err)) + } + if !ok || nullable { + return name.Pointer() + } else if ok && !nullable { + return name.Value() + } + } + return name +} + +func importableTypeName(c Context, f pgs.Field, e pgs.Entity) TypeName { t := TypeName(c.Name(e)) if c.ImportPath(e) == c.ImportPath(f) { @@ -42,13 +73,13 @@ func (c context) importableTypeName(f pgs.Field, e pgs.Entity) TypeName { return TypeName(fmt.Sprintf("%s.%s", c.PackageName(e), t)) } -func (c context) elType(ft pgs.FieldType) TypeName { +func elType(c Context, ft pgs.FieldType) TypeName { el := ft.Element() switch { case el.IsEnum(): - return c.importableTypeName(ft.Field(), el.Enum()) + return importableTypeName(c, ft.Field(), el.Enum()) case el.IsEmbed(): - return c.importableTypeName(ft.Field(), el.Embed()).Pointer() + return importableTypeName(c, ft.Field(), el.Embed()).Pointer() default: return scalarType(el.ProtoType()) } diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..4b554d9 --- /dev/null +++ b/tools.go @@ -0,0 +1,10 @@ +// +build tools + +package tools + +import ( + _ "github.com/gogo/protobuf/gogoproto" + _ "github.com/golang/protobuf/protoc-gen-go" + _ "golang.org/x/lint/golint" + _ "golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow" +)