You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#!/bin/bash
OS = "local"
while getopts "lh:" arg
do
case $arg in
h) #help带all参数仅用于测试脚本, 并备忘
echo "-h [all] help"
case $OPTARG in
all)
echo "-l build linux bin, default local"
; ;
esac
exit
; ;
l)
OS = "linux"
; ;
?)
echo "unkonw argument"
echo "-h all help"
echo "-l build linux bin, default local"
exit 1
; ;
esac
done
# Go Path
# CURDIR=`pwd`
# OLDGOPATH="$GOPATH"
# export GOPATH="$OLDGOPATH:$CURDIR"
LogPrefix = ">>>>"
# 打包前检测Bindata是否开启
echo -e " $LogPrefix `date + " %H:%M:%S"` \033[42;37m start \033[0m"
# echo "$LogPrefix `date +"%H:%M:%S"` src package"
# gofmt -w src/
# 交叉编译
case $OS in
linux)
# Linux
echo " $LogPrefix `date + " %H:%M:%S"` build linux bin"
CGO_ENABLED = 0 GOOS = linux GOARCH = amd64 go build -a -installsuffix cgo -ldflags '-w' -o mygo ./main.go
# go build -o mygo ./main.go
; ;
*)
# 本机
echo " $LogPrefix `date + " %H:%M:%S"` build local bin"
go build -a -installsuffix cgo -ldflags '-w' -o mygo ./main.go
; ;
esac
echo -e " $LogPrefix `date + " %H:%M:%S"` \033[42;37m finished \033[0m"