From 4cd06c960ad51d11703130fa7f4b61423cc3a619 Mon Sep 17 00:00:00 2001 From: liaochuntao Date: Tue, 30 May 2023 14:46:31 +0800 Subject: [PATCH] style:fix code style (#51) --- examples/circuitbreak/consumer/main.go | 15 ++++++++------- examples/routing/consumer/main.go | 6 +++--- import-format.sh | 21 +++++++++++++++------ resolver.go | 1 + 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/examples/circuitbreak/consumer/main.go b/examples/circuitbreak/consumer/main.go index b8912b9..c9e7935 100644 --- a/examples/circuitbreak/consumer/main.go +++ b/examples/circuitbreak/consumer/main.go @@ -20,13 +20,6 @@ package main import ( "context" "fmt" - polaris "github.com/polarismesh/grpc-go-polaris" - "github.com/polarismesh/polaris-go/api" - "github.com/polarismesh/polaris-go/pkg/model" - "google.golang.org/grpc" - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/status" "log" "net" "net/http" @@ -34,7 +27,15 @@ import ( "strings" "time" + "github.com/polarismesh/polaris-go/api" + "github.com/polarismesh/polaris-go/pkg/model" + "google.golang.org/grpc" + "google.golang.org/grpc/balancer" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + _ "github.com/polarismesh/grpc-go-polaris" + polaris "github.com/polarismesh/grpc-go-polaris" "github.com/polarismesh/grpc-go-polaris/examples/common/pb" ) diff --git a/examples/routing/consumer/main.go b/examples/routing/consumer/main.go index d6ac5cd..a9fba0d 100644 --- a/examples/routing/consumer/main.go +++ b/examples/routing/consumer/main.go @@ -20,9 +20,6 @@ package main import ( "context" "fmt" - polaris "github.com/polarismesh/grpc-go-polaris" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" "log" "net" "net/http" @@ -30,9 +27,12 @@ import ( "strings" "time" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" _ "github.com/polarismesh/grpc-go-polaris" + polaris "github.com/polarismesh/grpc-go-polaris" "github.com/polarismesh/grpc-go-polaris/examples/common/pb" ) diff --git a/import-format.sh b/import-format.sh index f689e4b..d2a3d09 100644 --- a/import-format.sh +++ b/import-format.sh @@ -25,16 +25,25 @@ mkdir -p style_tool cd style_tool -wget https://github.com/incu6us/goimports-reviser/releases/download/v3.3.0/goimports-reviser_3.3.0_darwin_arm64.tar.gz -tar -zxvf goimports-reviser_3.3.0_darwin_arm64.tar.gz +is_arm=$(/usr/bin/uname -m | grep "arm|aarch64" | wc -l) +goimports_target_file="goimports-reviser_3.3.1_linux_amd64.tar.gz" + +if [ "$(uname)" == "Darwin" ]; then + if [ "${is_arm}" == "1" ]; then + goimports_target_file="goimports-reviser_3.3.1_darwin_arm64.tar.gz" + else + goimports_target_file="goimports-reviser_3.3.1_darwin_amd64.tar.gz" + fi +fi + +wget "https://github.com/incu6us/goimports-reviser/releases/download/v3.3.1/${goimports_target_file}" +tar -zxvf ${goimports_target_file} mv goimports-reviser ../ cd ../ -find . -name "*.go" -type f | grep -v .pb.go|grep -v test/tools/tools.go | grep -v ./plugin.go | xargs -I {} ./goimports-reviser -rm-unused -format {} -project-name github.com/polarismesh/grpc-go-polaris - # 处理 go 代码格式化 go fmt ./... -# 检查 golangci-lint -docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.50.1 golangci-lint run -v +find . -name "*.go" -type f | grep -v .pb.go | grep -v test/tools/tools.go | grep -v ./plugin.go | + xargs -I {} ./goimports-reviser -rm-unused -format {} -local github.com/polarismesh/specification -project-name github.com/polarismesh/polaris diff --git a/resolver.go b/resolver.go index 676fc6c..35c48ea 100644 --- a/resolver.go +++ b/resolver.go @@ -167,6 +167,7 @@ func getNamespace(options *dialOptions) string { } const keyDialOptions = "options" + const keyResponse = "response" func (pr *polarisNamingResolver) lookup() (*resolver.State, api.ConsumerAPI, error) {