修改我正在使用的包的底层Go子依赖关系。

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

Modify underlying Go sub dependency on the package I am using

问题

我在尝试更新我的依赖项时,通过go mod tidy命令遇到了这个错误。我主要正在开发一个用于与cert-manager一起使用的webhook服务,但我无法解决这个依赖问题,因为我所依赖的包是由其他开发人员创建的,我无法控制这些“子依赖项”。

这是我的输出:

go.opentelemetry.io/otel/semconv: 找到模块 go.opentelemetry.io/otel@latest (v1.9.0),但不包含包 go.opentelemetry.io/otel/semconv

我在这里查找了该包:https://pkg.go.dev/go.opentelemetry.io/otel/semconv

对我来说,问题似乎是该包已经被重构为以下形式:

go.opentelemetry.io/otel/semconv/v1.9.0

作为子目录而不是包版本。

有没有办法我可以操纵我服务所依赖的包的底层依赖关系?

如果您需要更多信息,请留下评论。

请查看已接受解决方案的评论。

英文:

I am getting this error from go mod tidy when I am trying to update my dependancies. I am primarily developing a webhook service to use with cert-manager and I cannot figure out how to resolve this dependency isssue since the packages I am dependent on are created by other developers and I cannot control those "sub dependency".

This is my output:

go.opentelemetry.io/otel/semconv: module go.opentelemetry.io/otel@latest found (v1.9.0), but does not contain package go.opentelemetry.io/otel/semconv

I looked the package up here: https://pkg.go.dev/go.opentelemetry.io/otel/semconv

and the problem for me seems like that the package have been restructured like this:

go.opentelemetry.io/otel/semconv/v1.9.0

as a subdirectory instead of package version.

Is there a way I can manipulate the underlying dependancy of the packages that my service is depending on?

Please leave a comment if you need addictional information.

Take a look at the accepted solution's comments

答案1

得分: 2

你可能想使用本地副本的模块,这样你就可以修复问题并使用它。以下是操作步骤:

  1. 克隆模块存储库:git clone https://github.com/open-telemetry/opentelemetry-go.git
  2. 如果需要,切换到一个分支/标签:git checkout branch_name
  3. 在你的模块的 go.mod 文件中,添加以下行:
replace (
    go.opentelemetry.io => /path/where/cloned/opentelemetry-go
)
  1. 现在,你应该能够修改克隆的 opentelemetry-go 存储库中的代码,并在你的模块中使用它。
英文:

You may want to use a local copy of the module where you can fix the issue and use it. Steps for that

  1. Clone the module repository git clone https://github.com/open-telemetry/opentelemetry-go.git
  2. If needed, checkout to a branch/tag git checkout branch_name
  3. In the go.mod file of your module, add the following lines
replace (
    go.opentelemetry.io => /path/where/cloned/opentelemetry-go
)
  1. Now you should be able to modify code in the cloned opentelemetry-go repo and use it in your module

huangapple
  • 本文由 发表于 2022年8月29日 21:34:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/73529666.html
匿名

发表评论

匿名网友

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

确定