duan0714 2014-12-03 13:59
浏览 48
已采纳

Go工作区问题:如何将本地软件包与远程软件包区分开?

My gopath points to $HOME/go directory. And I have some personal packages that I don't want to share on github or anywhere else (yet). However when I try to update the remote packages with go get -u all I get:

# cd /home/go/src/marcio/somePackage; git pull --ff-only
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
package code.google.com/p/go.tools/astutil
        ...
        long list of dependencies
        ...
        imports marcio/somePackage: exit status 1

This is very confusing. How do I tell go get to differ the packages I maintain from the packages used as dependencies? Why the go tool thinks everything has to be fetched from a remote source?


UPDATE:

It looks like Go work spaces impose you to mix dependencies with user maintained code. This looks precarious. Sometimes ones want to wipe unused trash packages and live with the risk of wiping the wrong folder or uncommitted stuff, and many other problems... is there any way to keep user maintained packages separated from remote fetched dependencies?

  • 写回答

1条回答 默认 最新

  • dqst96444 2014-12-03 14:25
    关注

    go get -u is designed to fetch updates via VCS. If you want to selectively update packages, you'll have to use a more specific identifier. You still have the ... wildcard to use too.

    For example, this will try and update all packages from github.com:

    go get -u github.com/...
    

    In general though, I would avoid blindly updating everything, as it would make it harder to track when a dependency has broken something, since unrelated projects you're not currently working with will have their dependencies updated too.

    Update answer:

    While you can operate with multiple GOPATH's (they're colon separated just like PATH), don't do it; it will cause more problem than it helps with. Use a single GOPATH, and even better, use a single GOPATHper project. That way you can update dependencies without risk of affecting other projects. There's are some vendoring tools you can look into to help with this (godep for example)

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

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计