Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to investigate/fix: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules

When I do a go mod tidy (go v1.19), I am receiving the following error. I do see both packages in my go pkg directory. I assume that v1.6.1 is the most current version and is the one to keep. If this is true, how do I determine who is dragging in the older v0.34.0 version and correct it? I'd appreciate your suggestions.

Thank you for your time and interest, Mike

github.com/abc/runimage/v5/core/service imports
    github.com/grpc-ecosystem/go-grpc-middleware/auth tested by
    github.com/grpc-ecosystem/go-grpc-middleware/auth.test imports
    google.golang.org/grpc/credentials/oauth imports
    golang.org/x/oauth2/google imports
    cloud.google.com/go/compute/metadata: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
    cloud.google.com/go v0.34.0 (/Users/mike/Go/pkg/mod/cloud.google.com/[email protected]/compute/metadata)
    cloud.google.com/go/compute v1.6.1 (/Users/mike/Go/pkg/mod/cloud.google.com/go/[email protected]/metadata)
make: *** [tidy] Error 1
// go.mod 

module github.com/abc/runimage/v5

go 1.19

require (
    github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
    github.com/labstack/gommon v0.3.1
    google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58
    google.golang.org/grpc v1.48.0
    google.golang.org/protobuf v1.28.1
)

require (
    github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2
    github.com/joho/godotenv v1.4.0
)

require (
    github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect
    github.com/go-resty/resty/v2 v2.7.0 // indirect
    github.com/goccy/go-json v0.9.4 // indirect
    github.com/golang/protobuf v1.5.2 // indirect
    github.com/hashicorp/errwrap v1.0.0 // indirect
    github.com/hashicorp/go-multierror v1.1.1 // indirect
    github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
    github.com/lestrrat-go/blackmagic v1.0.0 // indirect
    github.com/lestrrat-go/httpcc v1.0.0 // indirect
    github.com/lestrrat-go/iter v1.0.1 // indirect
    github.com/lestrrat-go/jwx v1.2.18 // indirect
    github.com/lestrrat-go/option v1.0.0 // indirect
    github.com/mattn/go-colorable v0.1.12 // indirect
    github.com/mattn/go-isatty v0.0.14 // indirect
    github.com/okta/okta-jwt-verifier-golang v1.3.1 // indirect
    github.com/patrickmn/go-cache v0.0.0-20180815053127-5633e0862627 // indirect
    github.com/pkg/errors v0.9.1 // indirect
    github.com/valyala/bytebufferpool v1.0.0 // indirect
    github.com/valyala/fasttemplate v1.2.1 // indirect
    golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
    golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
    golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
    golang.org/x/text v0.3.7 // indirect
)
like image 675
A Bit of Help Avatar asked Nov 22 '25 00:11

A Bit of Help


1 Answers

Try go get cloud.google.com/go/compute/metadata and then go mod tidy

like image 185
Maxim Vladimirsky Avatar answered Nov 24 '25 03:11

Maxim Vladimirsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!