Description

When go mod tidy get ambiguous import error

How to reproduce

$ go mod init tmt
$ go mod tidy
...
...
go: found github.com/jackc/pgx/v4/pgxpool in github.com/jackc/pgx/v4 v4.18.1
go: found github.com/markcheno/go-talib in github.com/markcheno/go-talib v0.0.0-20190307022042-cd53a9264d70
go: found github.com/golang/mock/gomock in github.com/golang/mock v1.6.0
tmt/internal/app imports
    github.com/gin-gonic/gin imports
    github.com/gin-gonic/gin/binding imports
    github.com/ugorji/go/codec: ambiguous import: found package github.com/ugorji/go/codec in multiple modules:
    github.com/ugorji/go v1.1.4 (/Users/timhsu/go/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
    github.com/ugorji/go/codec v1.2.9 (/Users/timhsu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.9)

Environment

  • go version: 1.20.2
  • gin version (or commit ref): latest
  • operating system: macOS 13.3

Comment From: GlebZabl

same issue on macOS 12.4

Comment From: GlebZabl

@Chindada try this go get -u github.com/ugorji/go go mod tidy

solved problem for me

Comment From: fifsky

You can use the following command to find the indirect dependency and upgrade it ``` go mod graph | grep ugorji/go@v1.1.4

or 

replace github.com/ugorji/go v1.1.4 => github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43 ```

Comment From: Chindada

thanks a lot, it works!