From 0c877a71bceb400c92f06c17b6fbb8f1a24de968 Mon Sep 17 00:00:00 2001 From: unconsolable Date: Tue, 11 Jan 2022 12:11:13 +0800 Subject: [PATCH] proto: replace retool by go mod (#359) --- proto/generate_go.sh | 6 ++---- proto/tools.json | 14 -------------- proto/tools/.gitignore | 1 + proto/tools/Makefile | 7 +++++++ proto/tools/go.mod | 8 ++++++++ proto/tools/go.sum | 4 ++++ proto/tools/mod_guard.go | 8 ++++++++ 7 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 proto/tools.json create mode 100644 proto/tools/.gitignore create mode 100644 proto/tools/Makefile create mode 100644 proto/tools/go.mod create mode 100644 proto/tools/go.sum create mode 100644 proto/tools/mod_guard.go diff --git a/proto/generate_go.sh b/proto/generate_go.sh index 5cc0481a..cdce57a2 100755 --- a/proto/generate_go.sh +++ b/proto/generate_go.sh @@ -25,12 +25,10 @@ if [ -z $(go env GOPATH) ]; then fi GOPATH=$(go env GOPATH) GO_PREFIX_PATH=github.com/pingcap-incubator/tinykv/proto/pkg -export PATH=$(pwd)/_tools/bin:$GOPATH/bin:$PATH +export PATH=$(pwd)/tools/bin:$GOPATH/bin:$PATH echo "install tools..." -GO111MODULE=off go get github.com/twitchtv/retool -# Ensure we're using the right versions of our tools (see tools.json). -GO111MODULE=off retool -base-dir=$(pwd) sync || exit 1 +cd tools && make && cd .. function collect() { file=$(basename $1) diff --git a/proto/tools.json b/proto/tools.json deleted file mode 100644 index 6e5fe082..00000000 --- a/proto/tools.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Tools": [ - { - "Repository": "github.com/gogo/protobuf/protoc-gen-gofast", - "Commit": "636bf0302bc95575d69441b25a2603156ffdddf1" - }, - { - "Repository": "golang.org/x/tools/cmd/goimports", - "Commit": "04b5d21e00f1f47bd824a6ade581e7189bacde87" - } - ], - "RetoolVersion": "1.3.7" - } - \ No newline at end of file diff --git a/proto/tools/.gitignore b/proto/tools/.gitignore new file mode 100644 index 00000000..6dd29b7f --- /dev/null +++ b/proto/tools/.gitignore @@ -0,0 +1 @@ +bin/ \ No newline at end of file diff --git a/proto/tools/Makefile b/proto/tools/Makefile new file mode 100644 index 00000000..c61034e8 --- /dev/null +++ b/proto/tools/Makefile @@ -0,0 +1,7 @@ +all: bin/goimports bin/protoc-gen-gofast + +bin/goimports: + go build -o $@ golang.org/x/tools/cmd/goimports + +bin/protoc-gen-gofast: + go build -o $@ github.com/gogo/protobuf/protoc-gen-gofast \ No newline at end of file diff --git a/proto/tools/go.mod b/proto/tools/go.mod new file mode 100644 index 00000000..baf8d8c9 --- /dev/null +++ b/proto/tools/go.mod @@ -0,0 +1,8 @@ +module github.com/pingcap-incubator/tinykv/proto/_tools + +require ( + github.com/gogo/protobuf v1.1.1 + golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 +) + +go 1.13 diff --git a/proto/tools/go.sum b/proto/tools/go.sum new file mode 100644 index 00000000..2cc3a774 --- /dev/null +++ b/proto/tools/go.sum @@ -0,0 +1,4 @@ +github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 h1:bsEj/LXbv3BCtkp/rBj9Wi/0Nde4OMaraIZpndHAhdI= +golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/proto/tools/mod_guard.go b/proto/tools/mod_guard.go new file mode 100644 index 00000000..02822560 --- /dev/null +++ b/proto/tools/mod_guard.go @@ -0,0 +1,8 @@ +// +build modguard + +package tools + +import ( + _ "github.com/gogo/protobuf/protoc-gen-gofast" + _ "golang.org/x/tools/cmd/goimports" +)