项目组织结构
yishiyaonie:go liuhanlin$ pwd
/Users/liuhanlin/qiniuwork/go
yishiyaonie:go liuhanlin$ ls
aone public qbox
所以设置gopath为pwd的内容:/Users/liuhanlin/qiniuwork/go
aone为新项目,public为公共的go库,qbox为第三方库。
提倡的写法
yishiyaonie:go liuhanlin$ $GOPATH
-bash: /Users/liuhanlin/qiniuwork/go/public:/Users/liuhanlin/qiniuwork/go/qbox/base/qiniu:/Users/liuhanlin/qiniuwork/go/qbox/base/docs:/Users/liuhanlin/qiniuwork/go/qbox/base/com:/Users/liuhanlin/qiniuwork/go/qbox/base/biz:/Users/liuhanlin/qiniuwork/go/qbox/base/portal:/Users/liuhanlin/qiniuwork/go/qbox/base/cgo:/Users/liuhanlin/qiniuwork/go/qbox/base/mockacc:/Users/liuhanlin/qiniuwork/go/aone: No such file or directory
将你的公共的库作为第一个,这样当你go get的时候,就会将公共库安装到这些地方,其他的库,链接到它的尾部,保证能在gopath中找到即可。
添加到尾部的env.sh书写方式为:
yishiyaonie:aone liuhanlin$ cat env.sh
export GOPATH=$GOPATH:$AONEROOT/aone
export PATH=$PATH:$AONEROOT/aone/bin
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)