From baeef49883272ef3e555953de1700f324f5e1c08 Mon Sep 17 00:00:00 2001 From: Alexander Plevako Date: Sat, 2 May 2020 15:21:36 +0300 Subject: [PATCH] #169 support go modules --- .gitignore | 2 ++ Makefile | 45 +++++++++++++++++++++++++++++++++++---------- go.mod | 14 ++++++++++++++ go.sum | 42 ++++++++++++++++++++++++++++++++++++++++++ tools.go | 22 ++++++++++++++++++++++ 5 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 tools.go diff --git a/.gitignore b/.gitignore index 1a4641c3..d04701c6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ build npm-debug.log /release +.idea +_tools \ No newline at end of file diff --git a/Makefile b/Makefile index 1e0e1d82..1cb90495 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,46 @@ -RETOOL=$(CURDIR)/_tools/bin/retool PATH := ${PWD}/bin:${PWD}/ENV/bin:${PATH} -DOCKER_RELEASE_IMAGE := golang:1.12.0-stretch +DOCKER_RELEASE_IMAGE := golang:1.14.0-stretch .DEFAULT_GOAL := all -all: setup test_all +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +BUILD_PATH := $(dir $(MKFILE_PATH)) -.PHONY: test test_all test_core test_clients test_go_client test_python_client generate release_gen +TOOLS_BIN ?= $(BUILD_PATH)_tools/bin +PROTOC_PATH ?= $(BUILD_PATH)_tools + +PROTOBUF_VERSION ?= 3.11.0 + +ifeq ($(UNAME_S),Darwin) + PROTOC_URL = https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOBUF_VERSION)/protoc-$(PROTOBUF_VERSION)-osx-x86_64.zip +else + PROTOC_URL = https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOBUF_VERSION)/protoc-$(PROTOBUF_VERSION)-linux-x86_64.zip +endif + +all: protoc setup test_all + +.PHONY: protoc test test_all test_core test_clients test_go_client test_python_client generate release_gen + +protoc: + @if [ ! -d $(PROTOC_PATH) ]; then\ + mkdir -p $(PROTOC_PATH)/bin;\ + fi + + @if [ ! -f $(PROTOC_PATH)/bin/protoc ]; then\ + echo "Installing $(PROTOC_URL) to $(PROTOC_PATH)";\ + curl -o protoc.zip -sSL $(PROTOC_URL);\ + unzip -u protoc.zip -d $(PROTOC_PATH);\ + rm -rf protoc.zip;\ + fi # Phony commands: generate: - PATH=$(CURDIR)/_tools/bin:$(PATH) GOBIN="${PWD}/bin" go install -v ./protoc-gen-... - $(RETOOL) do go generate ./... + GOBIN="${PWD}/bin" go install -v ./protoc-gen-... + PATH=$(TOOLS_BIN):$(PATH) go generate ./... test_all: setup test_core test_clients test_core: generate - $(RETOOL) do errcheck -blank ./internal/twirptest + GOBIN=$(TOOLS_BIN) errcheck -blank ./internal/twirptest go test -race $(shell go list ./... | grep -v /vendor/ | grep -v /_tools/) test_clients: test_go_client test_python_client @@ -27,9 +52,9 @@ test_python_client: generate build/clientcompat build/pycompat ./build/clientcompat -client ./build/pycompat setup: - ./install_proto.bash - GOPATH=$(CURDIR)/_tools go install github.com/twitchtv/retool/... - $(RETOOL) build + GOBIN=$(TOOLS_BIN) go install github.com/golang/protobuf/protoc-gen-go + GOBIN=$(TOOLS_BIN) go install github.com/kisielk/errcheck + GOBIN=$(TOOLS_BIN) go install github.com/gogo/protobuf/protoc-gen-gofast release_gen: git clean -xdf diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..dcb75cae --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/twitchtv/twirp + +go 1.14 + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/gogo/protobuf v0.0.0-20170425171430-30433562cfbf + github.com/golang/protobuf v1.2.1-0.20180919224659-7716a980bcee + github.com/kisielk/errcheck v1.2.0 + github.com/pkg/errors v0.8.0 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.2.0 + golang.org/x/tools v0.0.0-20200501205727-542909fd9944 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..48491491 --- /dev/null +++ b/go.sum @@ -0,0 +1,42 @@ +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/gogo/protobuf v0.0.0-20170425171430-30433562cfbf h1:evX9hv1hI7WT5tKhNDdnKPo7DfNoQWBG3RbFGQAuGX8= +github.com/gogo/protobuf v0.0.0-20170425171430-30433562cfbf/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/protobuf v1.2.1-0.20180919224659-7716a980bcee h1:+mVzS2zW4kko5TLp0Q543d7oHN8+gmBcR6HehSTbJCA= +github.com/golang/protobuf v1.2.1-0.20180919224659-7716a980bcee/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= +github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/stretchr/testify v1.2.0 h1:LThGCOvhuJic9Gyd1VBCkhyUXmO8vKaBFvBsJ2k03rg= +github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/yuin/goldmark v1.1.27/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-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +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-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563 h1:NIou6eNFigscvKJmsbyez16S2cIS6idossORlFtSt2E= +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-20200501205727-542909fd9944 h1:H2fcUfqnOlhuExePgcxfMRf98XwAWOF2pqkJTFTc2z0= +golang.org/x/tools v0.0.0-20200501205727-542909fd9944/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +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/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= diff --git a/tools.go b/tools.go new file mode 100644 index 00000000..c91a15f8 --- /dev/null +++ b/tools.go @@ -0,0 +1,22 @@ +// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may not +// use this file except in compliance with the License. A copy of the License is +// located at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// or in the "license" file accompanying this file. This file is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +//+build tools + +package tools + +import ( + _ "github.com/golang/protobuf/protoc-gen-go" + _ "github.com/kisielk/errcheck" + _ "github.com/gogo/protobuf/protoc-gen-gofast" +) \ No newline at end of file