52 lines
1.2 KiB
Bash
52 lines
1.2 KiB
Bash
#!/bin/bash
|
|
# CPU_architecture="darwin/amd64
|
|
# darwin/arm64
|
|
# freebsd/386
|
|
# freebsd/amd64
|
|
# freebsd/arm
|
|
# freebsd/arm64
|
|
# linux/386
|
|
# linux/amd64
|
|
# linux/arm
|
|
# linux/arm64
|
|
# linux/loong64
|
|
# linux/mips
|
|
# linux/mips64
|
|
# linux/mips64le
|
|
# linux/mipsle
|
|
# linux/ppc64
|
|
# linux/ppc64le
|
|
# linux/riscv64
|
|
# linux/s390x
|
|
# netbsd/386
|
|
# netbsd/amd64
|
|
# netbsd/arm
|
|
# netbsd/arm64
|
|
# openbsd/386
|
|
# openbsd/amd64
|
|
# openbsd/arm
|
|
# openbsd/arm64
|
|
# openbsd/mips64
|
|
# windows/386
|
|
# windows/amd64
|
|
# windows/arm
|
|
# windows/arm64"
|
|
|
|
#只打包两个版本
|
|
CPU_architecture="linux/amd64"
|
|
|
|
for line in $CPU_architecture
|
|
do
|
|
array=(${line//\// })
|
|
extension=""
|
|
if [ "${array[0]}" == "windows" ];then
|
|
extension=".exe"
|
|
fi
|
|
echo "Start compiling the system:${array[0]} architecture:${array[1]}"
|
|
# echo "CGO_ENABLED=0 GOOS=${array[0]} GOARCH=${array[1]} go build -o /root/web/${array[0]}_${array[1]}_main${extension}"
|
|
# CGO_ENABLED=0 GOOS=${array[0]} GOARCH=${array[1]} go build -o /root/web/${array[0]}_${array[1]}_main${extension}
|
|
CGO_ENABLED=1 GOOS=${array[0]} GOARCH=${array[1]} go build -ldflags "-linkmode external -extldflags '-static' -s -w" -o ${array[0]}_${array[1]}_main${extension}
|
|
cp ${array[0]}_${array[1]}_main${extension} /root/web/
|
|
|
|
done
|