go build project
1 #! /bin/bash 2 function gobuild(){ 3 flag=0 4 for file in `ls $1` 5 do 6 pa1=$1$file 7 pa2=$2$file 8 if [ -d $pa1 ] #注意此处之间一定要加上空格,否则会报错 9 then 10 #echo $1$file 11 #echo "$pa1 is directory" 12 #echo "gobuile $pa1/ $pa2/" 13 gobuild "$pa1/" "$pa2/" 14 if [ $? -eq 1 ] 15 then 16 #echo build:$pa2 17 go build $2$file 18 go install $2$file 19 fi 20 elif [[ $file == *.go ]] 21 then 22 #echo "$pa1 is go file" 23 flag=1 24 #else 25 #echo "$pa1 is nomal file" 26 fi 27 done 28 return $flag 29 } 30 #read_dir . 31 gobuild ~/go/src/
gobuild + project的绝对地址即可(project须在GOPATH下)
可以写到~/.bashrc里作为全局函数使用