-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux.sh
42 lines (32 loc) · 879 Bytes
/
linux.sh
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
35
36
37
38
39
40
41
42
#!/bin/bash
read -p "file_name: " file_name
to="${1:-all}"
build() {
local os=$1
local arch=$2
local ext=$3
echo "$os $arch"
export GOOS=$os
export GOARCH=$arch
export CGO_ENABLED=0
if [[ "$os" != "darwin" ]]; then
go build -o "bin/$file_name.$arch$ext" "$file_name.go"
else
go build -o "bin/$file_name.mac.$arch$ext" "$file_name.go"
fi
}
if [[ "$to" == "linux_amd64" || "$to" == "all" ]]; then
build "linux" "amd64" ".bin"
fi
if [[ "$to" == "linux_arm64" || "$to" == "all" ]]; then
build "linux" "arm64" ".bin"
fi
if [[ "$to" == "windows_amd64" || "$to" == "all" ]]; then
build "windows" "amd64" ".exe"
fi
if [[ "$to" == "windows_arm64" || "$to" == "all" ]]; then
build "windows" "arm64" ".exe"
fi
if [[ "$to" == "mac_arm64" || "$to" == "all" ]]; then
build "darwin" "arm64" ".bin"
fi