build.sh 871 字节
Newer Older
1 2 3 4 5 6 7 8 9
# 把前端转化成go
# go get -u github.com/UnnoTed/fileb0x
# fileb0x b0x.yaml

# 整体编译
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOPRIVATE=*.gitlab.com,*.gitee.com
go env -w GOSUMDB=off

J
jason 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
version="1.0.0"
read -t 5 -p "please input version(default:$version)" ver
if [ -n "${ver}" ];then
	version=$ver
fi


goVersion=$(go version | awk '{print $3}')
gitHash=$(git show -s --format=%H)
buildTime=$(date -d today +"%Y-%m-%d %H:%M:%S")

ldflags="-X 'mydtu/args.Version=$version' \
-X 'mydtu/args.goVersion=$goVersion' \
-X 'mydtu/args.gitHash=$gitHash' \
-X 'mydtu/args.buildTime=$buildTime'"
25 26

export GOOS=linux
27 28
export CGO_ENABLED=1

29
#go build -o MyDTU main.go
J
jason 已提交
30
go build -ldflags "$ldflags" -o mydtu-linux main.go
31 32 33

export GOOS=windows
#go build -o MyDTU.exe main.go
J
jason 已提交
34
go build -ldflags "$ldflags" -o mydtu-win64.exe main.go