From 04be821f78f619f5239b73e70bed426a8a638bb4 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 19 Oct 2020 14:23:00 +0800 Subject: [PATCH] gateway compile --- doc/COMPILE.md | 2 ++ doc/COMPILE_CN.md | 2 ++ python/pipeline/gateway/proxy_server.go | 2 +- python/util.py | 12 ++++++++---- tools/serving_build.sh | 3 +++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/doc/COMPILE.md b/doc/COMPILE.md index abb66084..640d599d 100644 --- a/doc/COMPILE.md +++ b/doc/COMPILE.md @@ -75,6 +75,8 @@ export PATH=$PATH:$GOPATH/bin ## Get go packages ```shell +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger go get -u github.com/golang/protobuf/protoc-gen-go diff --git a/doc/COMPILE_CN.md b/doc/COMPILE_CN.md index 2ddaaf71..392da7ed 100644 --- a/doc/COMPILE_CN.md +++ b/doc/COMPILE_CN.md @@ -72,6 +72,8 @@ export PATH=$PATH:$GOPATH/bin ## 获取 Go packages ```shell +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger go get -u github.com/golang/protobuf/protoc-gen-go diff --git a/python/pipeline/gateway/proxy_server.go b/python/pipeline/gateway/proxy_server.go index a74e7984..cadc1567 100644 --- a/python/pipeline/gateway/proxy_server.go +++ b/python/pipeline/gateway/proxy_server.go @@ -25,7 +25,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - gw "./proto" + gw "serving-gateway/proto" ) //export run_proxy_server diff --git a/python/util.py b/python/util.py index 0ae68c1e..03442a76 100644 --- a/python/util.py +++ b/python/util.py @@ -31,6 +31,10 @@ def find_package(pkgname): def gen_pipeline_code(package_name): + ret = os.system("cd {}/pipeline/gateway/ && go mod init serving-gateway". + format(package_name)) + ret = os.system("cd {}/pipeline/gateway/ && go mod vendor && go mod tidy". + format(package_name)) # pipeline service proto protoc.main(( '', @@ -44,8 +48,8 @@ def gen_pipeline_code(package_name): ret = os.system( "cd {}/pipeline/gateway/proto/ && " "../../../../../third_party/install/protobuf/bin/protoc -I. " - "-I$GOPATH/src " - "-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis " + "-I$GOPATH/pkg/mod " + "-I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway\@v1.15.2/third_party/googleapis " "--go_out=plugins=grpc:. " "gateway.proto".format(package_name)) if ret != 0: @@ -54,8 +58,8 @@ def gen_pipeline_code(package_name): ret = os.system( "cd {}/pipeline/gateway/proto/ && " "../../../../../third_party/install/protobuf/bin/protoc -I. " - "-I$GOPATH/src " - "-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis " + "-I$GOPATH/pkg/mod " + "-I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway\@v1.15.2/third_party/googleapis " "--grpc-gateway_out=logtostderr=true:. " "gateway.proto".format(package_name)) if ret != 0: diff --git a/tools/serving_build.sh b/tools/serving_build.sh index b3ccce10..52f4a85c 100644 --- a/tools/serving_build.sh +++ b/tools/serving_build.sh @@ -22,6 +22,9 @@ function init() { export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin + go env -w GO111MODULE=on + go env -w GOPROXY=https://goproxy.cn,direct + go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger go get -u github.com/golang/protobuf/protoc-gen-go -- GitLab