set -xe PROG=t.out if which git >/dev/null 2>&1; then if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then # 获取最新的 commit ID commit=$(git rev-parse --short=8 HEAD) # 获取当前分支名 branch=$(git rev-parse --abbrev-ref HEAD) version=$(git describe --tags --always | sed 's/-/+/' | sed 's/^v//') static=`date +%Y%m%d_%H:%M:%S%z` echo "build git repo info version: $version branch: $branch commit: $commit static: $static" fi fi go build \ -ldflags "-X grace/gracedemo/manifest.Version=$version -X grace/gracedemo/manifest.Commit=$commit -X grace/gracedemo/manifest.Branch=$branch -X grace/gracedemo/manifest.Static=$static" \ -o ${PROG} #nohup ./${PROG} app.json 2>&1 & ./${PROG} > nohup.out