Golang 应用多平台批量编译脚本,Mac 环境,linux、darwin、freebsd、windows,amd64、386。
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/sh
project_name="yourapp"
release_version="0.0.1"
release_dir=./release
rm -rf $release_dir/*
mkdir -p $release_dir
cd $(dirname $0)
gofmt -w ./
for goos in "linux" "darwin" "freebsd" "windows"
do
if [ "$goos" == "windows" ]; then
obj_name=$project_name.exe
else
obj_name=$project_name
fi
GOOS=$goos GOARCH=amd64 go build
zip $release_dir/$project_name-$goos-amd64.zip $obj_name
GOOS=$goos GOARCH=386 go build
zip $release_dir/$project_name-$goos-386.zip $obj_name
rm -f $obj_name
done
cd $release_dir
for file in ./*
do
md5 -r $file >> sha1sum.txt
done
本文网址: https://golangnote.com/topic/215.html 转摘请注明来源