GoPATH 的设置编译比较麻烦,写一个脚本在 项目目录下运行,进行直接编译:
! /bin/bash
oldGOPATH=$GOPATH
nowPATH=`pwd`
export GOPATH=$oldGOPATH:$nowPATH
echo "GOPATH = $GOPATH"
go install $@
export GOPATH=$oldGOPATH`
每次都记不住 这个结构,编译的时候总找不到包, 弄个脚本创建项目目录:
#!/bin/bash
function usage(){
echo "usage :"
echo "$0 projectName"
}
if [ $# != 1 ]; then
usage
fi
projectName=$1
dir=$projectName"Proj"
mkdir $dir
pushd $dir
mkdir -p src/$projectName
pushd src/$projectName
touch $projectName.go
popd
popd
echo "create $projectName project success !"