-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
77 additions
and
32 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# 任何语句的执行结果不是true则应该退出 | ||
set -e | ||
apphash=`git log --pretty=format:'%h' -1` | ||
if [ $? -ne 0 ]; then | ||
apphash="zxysilent" | ||
fi | ||
appname="blog" | ||
echo "git log $apphash" | ||
# flags="-X 'main.Var=$apphashn'" | ||
# -w 去掉调试信息 | ||
# -s 去掉符号表 | ||
flags="" | ||
# -a 强制重新构建 | ||
# -n 打印编译时会用到的所有命令,但不真正执行 | ||
# -x 打印编译时会用到的所有命令 | ||
# -race 开启竞态检测 | ||
|
||
buildProd(){ | ||
go build -tags=prod -ldflags "$flags" -o $appname.exe main.go | ||
} | ||
buildDev(){ | ||
go build -ldflags "$flags" -o $appname.exe main.go | ||
} | ||
usage() { | ||
echo "Usage: $0 [-p <prod>] [-d <dev>]" 1>&2; | ||
} | ||
while getopts "pd" o; do | ||
case "${o}" in | ||
p) | ||
echo "build prod" | ||
buildProd | ||
;; | ||
d) | ||
echo "build dev" | ||
buildDev | ||
;; | ||
*) | ||
usage | ||
exit 0 | ||
;; | ||
esac | ||
done | ||
if [ "$#" -eq 0 ] ; then | ||
usage | ||
echo "build dev" | ||
buildDev | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.