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 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,