【问题标题】:Module name alias in go.modgo.mod 中的模块名称别名
【发布时间】:2021-10-13 04:29:01
【问题描述】:

有没有办法在模块中使用更短的名称表示/映射?

我有一个项目,有一个 url 命名:

module github.com/<org>/<project>    
go 1.14

如果能这样做就好了:

import "<short_name>/<project>/package_folder"

来自go.mod,类似:

module github.com/<org>/<project> => short_name
go 1.14

【问题讨论】:

    标签: go go-modules


    【解决方案1】:

    不,没有办法在go.mod 文件中定义别名。

    它是proposed,但由于here 解释的原因被拒绝。

    【讨论】:

      【解决方案2】:

      我最近遇到了一个命名不佳的内部存储库。 Go 不会这样做,但通过一些 git 魔法你可以接近。

      在你的 ~/.gitconfig 中添加如下内容: [网址“ssh://git@github.com//”] 相反 = https://github.com//

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-09-04
        • 1970-01-01
        • 1970-01-01
        • 2013-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-26
        相关资源
        最近更新 更多