golang 处理多个项目src编译问题 2.0
和之前那个版本区分开来,改了一下脚本代码,支持多个package
export GOPATH=$HOME/pj/go02 export PATH=$PATH:$GOPATH/bin export GOBIN=$GOPATH/bin export GOSRC=$GOPATH/src all: cd $GOPATH/src for file in $GOPATH/src/* do if test -d $file then echo ${file:(${#GOSRC}+1):${#file}} export PACKAGENAME=${file:(${#GOSRC}+1):${#file}} rm -rf $GOPATH/bin/$PACKAGENAME mkdir $GOPATH/bin/$PACKAGENAME for gofile in $file/*.go do if test -f $gofile then export GOBIN=$GOPATH/bin/$PACKAGENAME echo $gofile" is building..." go install $gofile echo "done" fi done fi done run: #注释掉 :<<word for file in $GOBIN/* do if test -f $file then echo "build" $file "success" else echo "build" $file "failed" fi done word
有疑问加站长微信联系(非本文作者)