【问题标题】:import from specific branch github in the same repository where it is hosted从托管它的同一存储库中的特定分支 github 导入
【发布时间】:2021-07-31 16:18:40
【问题描述】:

我在 Github 中有一个带有 Go 项目的存储库,我需要在一个模块中导入一个特定的分支,以进行相关修改。它看起来像这样:

import (
    "github.com/repository/utils/date_utils"
    "github.com/repository/utils/utils/error_utils"
    "github.com/repository/utils/utils/hour_utils"
    "strconv"
    "strings"
)

导入总是直接从主服务器完成。我只需要这个模块从不同的分支导入。

【问题讨论】:

标签: go


【解决方案1】:

你可以使用

go get <path-to-repo>@<branch>

来自documentation

Get 将其命令行参数解析为特定模块的包 版本,更新 go.mod 以需要这些版本,下载源 代码到模块缓存中,然后构建并安装命名的 包

documentation 上的这一行也很有趣。

使用诸如 go get foo@master (foo@default with mercurial) 之类的分支名称是获取最新提交的一种方法,无论它是否具有 semver 标记。

【讨论】:

  • 我可以直接从 de 仓库修改吗? de go.mod 然后是模块?我不能使用命令行。对不起,我是新来使用 go
猜你喜欢
  • 2020-03-16
  • 2021-05-05
  • 1970-01-01
  • 2012-12-10
  • 2018-04-04
  • 1970-01-01
  • 2017-04-03
  • 1970-01-01
  • 2020-06-27
相关资源
最近更新 更多