go_echo_wol/bulid.sh

51 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2023-09-13 10:05:09 +08:00
#!/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"
#只打包两个版本
2023-09-25 16:22:34 +08:00
CPU_architecture="linux/amd64"
2023-09-13 10:05:09 +08:00
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}"
2023-09-25 11:17:45 +08:00
# CGO_ENABLED=0 GOOS=${array[0]} GOARCH=${array[1]} go build -o /root/web/${array[0]}_${array[1]}_main${extension}
2023-09-25 17:10:30 +08:00
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/
2023-09-13 10:05:09 +08:00
done