Golang私有模块(v1.17)–找到了包,但不包含该包。

huangapple go评论91阅读模式
英文:

Golang Private Modules (v1.17) -- package found but does not contain the package

问题

回顾了许多文章后,遇到了这个问题:

1)在我的git账户中创建了一个私有包'mypackage'
2)在git中,我有MyCompany/mypackage
3)在另一个项目中,我想导入这个包:

...
import (
    "github.com/MyCompany/mypackage'
)

4)当我运行:

go mod tidy

我得到以下错误:

github.com/MyCompany/mypackage: 找到模块github.com/MyCompany/mypackage@latest(v0.0.0-20220126203606-a88fea44b771),但不包含包github.com/MyCompany/mypackage

不确定如何解决这个问题。

在我的.gitconfig文件中,我有:

insteadOf = https://github.com/

go env

显示以下设置:

GOPRIVATE="github.com/MyCompany/*"
GONOPROXY="github.com/MyCompany/*"
GONOSUMDB="github.com/MyCompany/*"

我还缺少哪些其他配置?

go.mod文件如下所示:

module github.com/MyCompany/mypackage

go 1.17

require (
    github.com/go-redis/redis/v8 v8.11.4
    github.com/pkg/errors v0.9.1
)

require (
    github.com/cespare/xxhash/v2 v2.1.2 // indirect
    github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
)
英文:

Reviewing numerous articles, running into this issue:

  1. Created a private package, 'mypackage' in my git account

  2. In git, I have MyCompany/mypackage

  3. In another project, I want to import the package:

    ...
    import (
       "github.com/MyCompany/mypackage'
    )
    
  4. When I run:

    go mod tidy
    

I get the following error:

github.com/MyCompany/mypackage: module github.com/MyCompany/mypackage@latest found (v0.0.0-20220126203606-a88fea44b771), but does not contain package github.com/MyCompany/mypackage

Not sure how to resolve this.

In my .gitconfig I have:

insteadOf = https://github.com/

<!-- -->

go env 

shows these settings:

GOPRIVATE=&quot;github.com/MyCompany/*&quot;
GONOPROXY=&quot;github.com/MyCompany/*&quot;
GONOSUMDB=&quot;github.com/MyCompany/*&quot;

What other configurations am I missing?

The go.mod file looks like:

module github.com/MyCompany/mypackage

go 1.17

require (
    github.com/go-redis/redis/v8 v8.11.4
    github.com/pkg/errors v0.9.1
)

require (
    github.com/cespare/xxhash/v2 v2.1.2 // indirect
    github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
)

答案1

得分: 1

已添加一个语义版本标签(git tag v1.0.0,git push --tags),然后可以下载。

英文:

Added a semver tag (git tag v1.0.0, git push --tags) then was able to download

huangapple
  • 本文由 发表于 2022年1月27日 05:39:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/70870607.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定