doubeiji2602 2018-05-25 15:22
浏览 1612

所有Go项目都需要位于GOPATH下吗? [重复]

I am starting with Go and trying to get my head around GOPATH (and probably GOBIN).

When trying to fetch external libraries via go get I get the error

go get: no install location for directory D:\Seafile\dev-perso\domotiqueNG\services\dispatcher-go\src\dispatcher-go outside GOPATH

This error is apparently solved by having a project structure below $GOPATH/src.

Does this mean that all my Go programs must live there? If GOPATH is d:\hello then the projects bonjour and aurvoir really need to be in

d:\hello\src\bonjour
d:\hello\src\aurevoir

only ?

In this is the case how can I

  • split, say, personal and professional projects when the personal must stay at d:\home and professional at x:\work ?
  • have multilanguage projects where d:\home\domotique\dispatch is in Go, d:\home\domotique\whatever is in Python, and I have several such combos in d:\home?
</div>
  • 写回答

2条回答 默认 最新

  • duanhuanbo5225 2018-05-25 17:13
    关注

    When using the GOPATH you can make subdirectories in the /src folder, for example, adding both home and work directories. In fact, the Go project has an example of how to organize code. While packages need to be in their own folders, a folder itself in the GOPATH is not automatically a package.

    If you'd rather not work within the confines of the GOPATH, you can change it to the path you do want to work in, or set it to your home directory.

    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名