Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous import #180

Open
ldez opened this issue Mar 4, 2022 · 5 comments
Open

ambiguous import #180

ldez opened this issue Mar 4, 2022 · 5 comments

Comments

@ldez
Copy link

ldez commented Mar 4, 2022

The problem described in #172 is still here:

$ go mod tidy
github.com/traefik/traefik/v2/pkg/provider/acme imports
        github.com/go-acme/lego/v4/providers/dns imports
        github.com/go-acme/lego/v4/providers/dns/tencentcloud imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common: ambiguous import: found package github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common in multiple modules:
        github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go@v3.0.83+incompatible/tencentcloud/common)
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.353 (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.353)
github.com/traefik/traefik/v2/pkg/provider/acme imports
        github.com/go-acme/lego/v4/providers/dns imports
        github.com/go-acme/lego/v4/providers/dns/tencentcloud imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile: ambiguous import: found package github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile in multiple modules:
        github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go@v3.0.83+incompatible/tencentcloud/common/profile)
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.353 (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.353/profile)
github.com/traefik/traefik/v2/pkg/provider/acme imports
        github.com/go-acme/lego/v4/providers/dns imports
        github.com/go-acme/lego/v4/providers/dns/tencentcloud imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323 imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors: ambiguous import: found package github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors in multiple modules:
        github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go@v3.0.83+incompatible/tencentcloud/common/errors)
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.353 (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.353/errors)
github.com/traefik/traefik/v2/pkg/provider/acme imports
        github.com/go-acme/lego/v4/providers/dns imports
        github.com/go-acme/lego/v4/providers/dns/tencentcloud imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323 imports
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http: ambiguous import: found package github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http in multiple modules:
        github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go@v3.0.83+incompatible/tencentcloud/common/http)
        github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.353 (/home/ldez/sources/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.353/http)

I think the problem can be related to the fact that github.com/tencentcloud/tencentcloud-sdk-go breaks the version continuity by moving from v3 to v1.

Maybe a solution can be to retract the old v3 modules:

go.mod
// ...

retract (
	v3.0.233+incompatible
	v3.0.232+incompatible
	v3.0.231+incompatible
	v3.0.230+incompatible
	v3.0.229+incompatible
	v3.0.228+incompatible
	v3.0.227+incompatible
	v3.0.226+incompatible
	v3.0.225+incompatible
	v3.0.224+incompatible
	v3.0.223+incompatible
	v3.0.222+incompatible
	v3.0.221+incompatible
	v3.0.220+incompatible
	v3.0.219+incompatible
	v3.0.218+incompatible
	v3.0.217+incompatible
	v3.0.216+incompatible
	v3.0.215+incompatible
	v3.0.214+incompatible
	v3.0.213+incompatible
	v3.0.212+incompatible
	v3.0.211+incompatible
	v3.0.210+incompatible
	v3.0.209+incompatible
	v3.0.208+incompatible
	v3.0.207+incompatible
	v3.0.206+incompatible
	v3.0.205+incompatible
	v3.0.204+incompatible
	v3.0.203+incompatible
	v3.0.202+incompatible
	v3.0.201+incompatible
	v3.0.200+incompatible
	v3.0.199+incompatible
	v3.0.198+incompatible
	v3.0.197+incompatible
	v3.0.196+incompatible
	v3.0.195+incompatible
	v3.0.194+incompatible
	v3.0.193+incompatible
	v3.0.192+incompatible
	v3.0.191+incompatible
	v3.0.190+incompatible
	v3.0.189+incompatible
	v3.0.188+incompatible
	v3.0.187+incompatible
	v3.0.186+incompatible
	v3.0.185+incompatible
	v3.0.184+incompatible
	v3.0.183+incompatible
	v3.0.182+incompatible
	v3.0.181+incompatible
	v3.0.180+incompatible
	v3.0.179+incompatible
	v3.0.178+incompatible
	v3.0.177+incompatible
	v3.0.176+incompatible
	v3.0.175+incompatible
	v3.0.174+incompatible
	v3.0.173+incompatible
	v3.0.172+incompatible
	v3.0.171+incompatible
	v3.0.170+incompatible
	v3.0.169+incompatible
	v3.0.168+incompatible
	v3.0.167+incompatible
	v3.0.166+incompatible
	v3.0.165+incompatible
	v3.0.164+incompatible
	v3.0.163+incompatible
	v3.0.162+incompatible
	v3.0.161+incompatible
	v3.0.160+incompatible
	v3.0.159+incompatible
	v3.0.158+incompatible
	v3.0.157+incompatible
	v3.0.156+incompatible
	v3.0.155+incompatible
	v3.0.154+incompatible
	v3.0.153+incompatible
	v3.0.152+incompatible
	v3.0.151+incompatible
	v3.0.150+incompatible
	v3.0.149+incompatible
	v3.0.148+incompatible
	v3.0.147+incompatible
	v3.0.146+incompatible
	v3.0.145+incompatible
	v3.0.144+incompatible
	v3.0.143+incompatible
	v3.0.142+incompatible
	v3.0.141+incompatible
	v3.0.140+incompatible
	v3.0.139+incompatible
	v3.0.138+incompatible
	v3.0.137+incompatible
	v3.0.136+incompatible
	v3.0.135+incompatible
	v3.0.134+incompatible
	v3.0.133+incompatible
	v3.0.132+incompatible
	v3.0.131+incompatible
	v3.0.130+incompatible
	v3.0.129+incompatible
	v3.0.128+incompatible
	v3.0.127+incompatible
	v3.0.126+incompatible
	v3.0.125+incompatible
	v3.0.124+incompatible
	v3.0.123+incompatible
	v3.0.121+incompatible
	v3.0.120+incompatible
	v3.0.119+incompatible
	v3.0.118+incompatible
	v3.0.117+incompatible
	v3.0.116+incompatible
	v3.0.115+incompatible
	v3.0.114+incompatible
	v3.0.113+incompatible
	v3.0.112+incompatible
	v3.0.111+incompatible
	v3.0.110+incompatible
	v3.0.109+incompatible
	v3.0.108+incompatible
	v3.0.107+incompatible
	v3.0.106+incompatible
	v3.0.105+incompatible
	v3.0.104+incompatible
	v3.0.103+incompatible
	v3.0.102+incompatible
	v3.0.101+incompatible
	v3.0.100+incompatible
	v3.0.99+incompatible
	v3.0.98+incompatible
	v3.0.97+incompatible
	v3.0.96+incompatible
	v3.0.95+incompatible
	v3.0.94+incompatible
	v3.0.93+incompatible
	v3.0.92+incompatible
	v3.0.91+incompatible
	v3.0.90+incompatible
	v3.0.89+incompatible
	v3.0.88+incompatible
	v3.0.87+incompatible
	v3.0.86+incompatible
	v3.0.85+incompatible
	v3.0.84+incompatible
	v3.0.83+incompatible
	v3.0.82+incompatible
	v3.0.81+incompatible
	v3.0.80+incompatible
	v3.0.79+incompatible
	v3.0.78+incompatible
	v3.0.77+incompatible
	v3.0.76+incompatible
	v3.0.75+incompatible
	v3.0.74+incompatible
	v3.0.73+incompatible
	v3.0.72+incompatible
	v3.0.71+incompatible
)

@ldez ldez changed the title when github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod is used as a transitive dependency an error occurs: ambiguous import Mar 4, 2022
@anil-kumar-b
Copy link

anil-kumar-b commented Nov 22, 2022

Hi @ldez, getting the same error when trying to update github.com/hashicorp/packer.

`github.com/hashicorp/packer imports

github.com/hashicorp/packer/command imports

github.com/hashicorp/packer-plugin-tencentcloud/builder/tencentcloud/cvm imports

github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common: ambiguous import: found package 

github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common in multiple modules:

github.com/tencentcloud/tencentcloud-sdk-go v3.0.233+incompatible 

(/home/anil.b/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go@v3.0.233+incompatible/tencentcloud/common)

github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.367 

(/home/anil.b/go/pkg/mod/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.367)`

how do you solve this problem?

@ldez
Copy link
Author

ldez commented Nov 23, 2022

I solve the problem by adding exclude directives in the go.mod.

exclude github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible

@sesky4
Copy link
Collaborator

sesky4 commented Dec 7, 2022

v3.x.x is deprecated. SDK has moved to v1.x.x to confirm to the go module version standard.

I believe the problem is due the go.mod added in every tencentcloud/xxx after v3.0.83 confused the go compiler ( which doesn't exist at v3.0.83 ).

the compiler doesn't know where to find the common packge:

github.com/tencentcloud/tencentcloud-sdk-go@v3.0.83/tencentcloud/common ( module: tencnetcloud-sdk-go, subdir: /tencentcloud/common )
or
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common@v1.0.353 ( module: tencnetcloud-sdk-go/tencentcloud/common, subdir: /)

go clean -modcache && go mod tidy may help, because there will be only one version of module left in your local module cache.

@ldez
Copy link
Author

ldez commented Dec 7, 2022

go clean -modcache && go mod tidy doesn't help.

The problem is due to the v3 exists without the right name (github.com/tencentcloud/tencentcloud-sdk-go/v3).
The v1 breaks the continuity of the version for the module.
The right approach would have been to create a v4 with the module name github.com/tencentcloud/tencentcloud-sdk-go/v4

@Tiper-In-Github
Copy link

The solution to the same problem is to fall back to version 756

go get -v github.com/tencentcloud/tencentcloud-sdk-go@v1.0.756

If you need to use the sms interface:

go get -v github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms@v1.0.756
go get -v github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111@v1.0.756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants