File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1
1
run :
2
2
go run * .go -o ./tmp
3
3
build :
4
- go build -o image-compressor
4
+ go build -o image-compressor
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ package=$1
3
+
4
+ if [[ -z " $package " ]]; then
5
+ echo " usage: $0 <package-name>"
6
+ exit 1
7
+ fi
8
+
9
+ package_name=$( basename " $package " )
10
+
11
+ platforms=(" linux/amd64" " linux/arm64" )
12
+
13
+ for platform in " ${platforms[@]} " ; do
14
+ IFS=' /' read -ra platform_split <<< " $platform"
15
+ GOOS=${platform_split[0]}
16
+ GOARCH=${platform_split[1]}
17
+ output_name=" $package_name " -" $GOOS " -" $GOARCH "
18
+
19
+ if [ " $GOOS " = " windows" ]; then
20
+ output_name+=' .exe'
21
+ fi
22
+ echo " CGO_ENABLE=1 GOOS='$GOOS ' GOARCH='$GOARCH ' go build -o '$output_name ' '$package '"
23
+ env CGO_ENABLE=1 GOOS=" $GOOS " GOARCH=" $GOARCH " go build -o " $output_name " " $package "
24
+
25
+ if [ $? -ne 0 ]; then
26
+ echo ' An error has occurred! Aborting the script execution...'
27
+ exit 1
28
+ fi
29
+ done
You can’t perform that action at this time.
0 commit comments