douduxia1551 2017-03-13 10:52
浏览 3817
已采纳

如何使用go get获取另一个分支而不是默认分支

I have 2 repositories. Let say them repo_a and repo_b. I imported repo_a in repo_b

When I ran go get, it will get repo_a master branch. Is there any way to get develop branch using go get or another command from repo_b?

I do not want to git pull on each specific package (in this case repo_a)

  • 写回答

3条回答 默认 最新

  • dongxia9519 2017-03-13 10:56
    关注

    Stable HEAD philosophy

    It is not possible with pure go get.

    Go takes the most minimal and pragmatic approach of any package manager. There is no such thing as multiple versions of a Go package.

    But this is not as bad as it seems at the first view because there exists a philosophy behind this behavior.

    As a package author, you must adhere to the stable HEAD philosophy. Your default branch must always be the stable, released version of your package. You must do work in feature branches and only merge when ready to release.

    This approach is forced by go get limitations and it should be treated like Python indentations - it is kind of philosophy forced by language design.

    Development approaches

    If you want to fork something or try new features you can clone repo then switch to a desired branch and do go build. This way shouldn't go to production.

    git clone <repo name>
    cd <repo name>
    git checkout <branch name>
    go build
    

    Also you can use third party package management tools. But most of them support tags and revisions, not branches (since it is implied that you don't need to install feature branch).

    gpm:

    You can specify packages with the format, where version can be a revision number (a git/bazaar/mercurial/svn revision hash) or a tag.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?