Search code examples
goopen-telemetrycert-manager

Modify underlying Go sub dependency on the package I am using


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


Solution

  • 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