douyi2107 2014-10-28 15:17
浏览 62
已采纳

Go项目工作区如何与依赖工具和go工具一起使用?

I have a project with packages inside:

  • project package "root": a/b/c (eg github/b/c)
  • in a/b/c we have a lot of packages (p1, p2 ...)
  • project is managed according to How to Write Go Code official recommendations. The local project path is: $GOPATH/src/a/b/c. Also all imports are "not relative".
  • the project has go get-able dependencies

Now I want to use some dependency manager tool like gom or godep. Each of this tool creates an extra directory in repository and puts all vendor dependencies there. Also it plays with GOPATH and sets it to that vendor directory. Let's assume that the tool will put all vendors in path_to_project/.vendor - becoming a new GOPATH.

I want to use one of the go tools (gofmt, gorename, ...) being aware about packages in my projects and vendor directory. The problem is that if GOPATH=path_to_project/.vendor (godep does this) then tools are not aware about packages in my project.

One idea for this is to set a GOPATH=path_to_project/.vendor:GOPATH in a shell end editors. Or call every command with gom exec (gom sets a GOPATH in the above proposition)

Is there any ready and automatic solution for this?

Final goal is to bundle go project with specified dependencies versions (like git commits) and make tools + editors (vim/emacs) working with this tools.

  • 写回答

1条回答 默认 最新

  • doulou9927 2014-11-14 15:25
    关注

    If you are using godep, you can just prefix the go command with godep like this:

    godep go build
    

    or

    godep go fmt 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测