-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimport-format.sh
More file actions
executable file
·34 lines (26 loc) · 1.14 KB
/
Copy pathimport-format.sh
File metadata and controls
executable file
·34 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# 格式化 go.mod
go mod tidy -compat=1.17
# docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:v2.0.2 golangci-lint run -v --timeout 30m
# 处理 go imports 的格式化
if [ ! -d "style_tool" ]; then
mkdir -p style_tool
cd style_tool
is_arm=$(/usr/bin/uname -m | grep -E "arm|aarch64" | wc -l)
goimports_target_file="goimports-reviser_3.9.1_linux_amd64.tar.gz"
if [ "$(uname)" == "Darwin" ]; then
if [ "${is_arm}" == "1" ]; then
goimports_target_file="goimports-reviser_3.9.1_darwin_arm64.tar.gz"
else
goimports_target_file="goimports-reviser_3.9.1_darwin_amd64.tar.gz"
fi
fi
wget "https://github.com/incu6us/goimports-reviser/releases/download/v3.9.1/${goimports_target_file}"
tar -zxvf ${goimports_target_file}
mv goimports-reviser ../
cd ../
fi
# 处理 go 代码格式化
go fmt ./...
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 -company-prefixes github.com/pole-io/specification -project-name github.com/pole-io/pole-server -format {}