diff --git a/.travis.yml b/.travis.yml index d3620c5..c481820 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,12 @@ go: "1.11" go_import_path: github.com/lyft/protoc-gen-star env: - global: - - GLIDE_VER="v0.13.1" matrix: - PROTOC_VER="3.5.1" - PROTOC_VER="3.6.1" before_install: - mkdir -p $GOPATH/bin - - wget "https://github.com/Masterminds/glide/releases/download/${GLIDE_VER}/glide-${GLIDE_VER}-linux-amd64.tar.gz" -O /tmp/glide.tar.gz - - tar -xvf /tmp/glide.tar.gz --strip-components 1 -C ${GOPATH}/bin - wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/protoc-${PROTOC_VER}-linux-x86_64.zip" -O /tmp/protoc.zip - unzip /tmp/protoc.zip -d /tmp - sudo mv /tmp/bin/protoc /usr/local/bin/protoc diff --git a/Makefile b/Makefile index e49719a..a5d29ed 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,10 @@ PKG := $(shell go list .) PKGS := $(shell go list ./...) +GO111MODULE=on + .PHONY: bootstrap -bootstrap: vendor testdata # set up the project for development +bootstrap: testdata # set up the project for development .PHONY: lint lint: # lints the package for common code smells @@ -11,20 +13,19 @@ lint: # lints the package for common code smells 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 $(PKGS) + go run golang.org/x/lint/golint -set_exit_status $(PKGS) go vet -all -shadow -shadowstrict $(PKGS) .PHONY: quick -quick: vendor testdata # runs all tests without the race detector or coverage +quick: testdata # runs all tests without the race detector or coverage go test $(PKGS) .PHONY: tests -tests: vendor testdata # runs all tests against the package with race detection and coverage percentage +tests: testdata # runs all tests against the package with race detection and coverage percentage go test -race -cover $(PKGS) .PHONY: cover -cover: vendor testdata # runs all tests against the package, generating a coverage report and opening it in the browser +cover: testdata # runs all tests against the package, generating a coverage report and opening it in the browser go test -race -covermode=atomic -coverprofile=cover.out $(PKGS) || true go tool cover -html cover.out -o cover.html open cover.html @@ -46,14 +47,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 @@ -72,25 +73,20 @@ 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 - -.PHONY: protoc-gen-go -protoc-gen-go: - which protoc-gen-go || (go get -u github.com/golang/protobuf/protoc-gen-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: vendor # creates the demo protoc plugin for demonstrating uses of PG* - go build -o ./bin/protoc-gen-example ./testdata/protoc-gen-example +bin/protoc-gen-example: # creates the demo protoc plugin for demonstrating uses of PG* + go build -o $@ ./testdata/protoc-gen-example -bin/protoc-gen-debug: vendor # creates the protoc-gen-debug protoc plugin for output ProtoGeneratorRequest messages - go build -o ./bin/protoc-gen-debug ./protoc-gen-debug +bin/protoc-gen-debug: # creates the protoc-gen-debug protoc plugin for output ProtoGeneratorRequest messages + go build -o $@ ./protoc-gen-debug .PHONY: clean clean: diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 0579926..0000000 --- a/glide.lock +++ /dev/null @@ -1,41 +0,0 @@ -hash: a98be71ff763a2b4b183feef097ec7a862c3d26d01cb7c7484975b8e10dabeb5 -updated: 2018-05-09T12:54:16.045343-07:00 -imports: -- name: github.com/golang/protobuf - version: b4deda0973fb4c70b50d226b1af49f3da59f5265 - subpackages: - - proto - - protoc-gen-go/descriptor - - protoc-gen-go/generator - - protoc-gen-go/generator/internal/remap - - protoc-gen-go/plugin -- name: github.com/spf13/afero - version: 63644898a8da0bc22138abf860edaf5277b6102e - subpackages: - - mem -- name: golang.org/x/net - version: 2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1 - subpackages: - - context -- name: golang.org/x/sync - version: 1d60e4601c6fd243af51cc01ddf169918a5407ca - subpackages: - - errgroup -- name: golang.org/x/text - version: e19ae1496984b1c655b8044a65c0300a3c878dd3 - subpackages: - - transform - - unicode/norm -testImports: -- name: github.com/davecgh/go-spew - version: 87df7c60d5820d0f8ae11afede5aa52325c09717 - subpackages: - - spew -- name: github.com/pmezard/go-difflib - version: 792786c7400a136282c1664665ae0a8db921c6c2 - subpackages: - - difflib -- name: github.com/stretchr/testify - version: a726187e3128d0a0ec37f73ca7c4d3e508e6c2e5 - subpackages: - - assert diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 727b21b..0000000 --- a/glide.yaml +++ /dev/null @@ -1,11 +0,0 @@ -package: github.com/lyft/protoc-gen-star -import: -- package: github.com/golang/protobuf - version: ^1.1.0 -- package: github.com/spf13/afero -- package: golang.org/x/text -- package: golang.org/x/sync - subpackages: - - errgroup -testImport: -- package: github.com/stretchr/testify diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c66d76a --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/lyft/protoc-gen-star + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang/protobuf v1.2.0 + github.com/spf13/afero v1.1.0 + github.com/stretchr/testify v1.3.0 + golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 + golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect + golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect + golang.org/x/tools v0.0.0-20180221164845-07fd8470d635 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4e98281 --- /dev/null +++ b/go.sum @@ -0,0 +1,21 @@ +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/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.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/afero v1.1.0 h1:bopulORc2JeYaxfHLvJa5NzxviA9PoWhpiiJkru7Ji4= +github.com/spf13/afero v1.1.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 h1:rJm0LuqUjoDhSk2zO9ISMSToQxGz7Os2jRiOL8AWu4c= +golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635 h1:2eB4G6bDQDeP69ZXbOKC00S2Kf6TIiRS+DzfKsKeQU0= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 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/tools.go b/tools.go new file mode 100644 index 0000000..368b3ca --- /dev/null +++ b/tools.go @@ -0,0 +1,8 @@ +// +build tools + +package tools + +import ( + _ "github.com/golang/protobuf/protoc-gen-go" + _ "golang.org/x/lint/golint" +)