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

cannot load github.com/ugorji/go/codec: ambiguous import: found github.com/ugorji/go/codec in multiple modules #17

Closed
marcoippolito opened this issue Jun 10, 2019 · 10 comments

Comments

@marcoippolito
Copy link

marcoippolito commented Jun 10, 2019

Ubuntu 18.04.01 Server Edition

marco@pc01:~/go$ go version
go version go1.12.5 linux/amd64


marco@pc01:~/go/pkg/mod/github.com$ ls -lah
total 36K
drwxrwxr-x 9 marco marco 4.0K Jun 10 15:31 .
drwxrwxr-x 8 marco marco 4.0K May 31 08:40 ..
drwxrwxr-x 5 marco marco 4.0K Jun 10 15:08 gin-contrib
drwxrwxr-x 4 marco marco 4.0K Jun 10 15:08 gin-gonic
drwxrwxr-x 4 marco marco 4.0K Jun 10 15:08 golang
drwxrwxr-x 8 marco marco 4.0K May 31 08:40 gonum
drwxrwxr-x 5 marco marco 4.0K May 31 08:40 hashicorp
drwxrwxr-x 4 marco marco 4.0K Jun 10 15:08 mattn
drwxrwxr-x 3 marco marco 4.0K May 31 08:40 pbnjay

When trying to execute the multiple-services example:

marco@pc01:~/go/marcoGolang/gin-examples/multiple-service$ go run main.go 
go: extracting github.com/ugorji/go v1.1.4
go: extracting github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2
build command-line-arguments: cannot load github.com/ugorji/go/codec: ambiguous import: 
found github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.4 (/home/marco/go/pkg/mod/github.com/ugorji/[email protected]/codec)
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/home/marco/go/pkg
/mod/github.com/ugorji/go/[email protected])
marco@pc01:~/go/marcoGolang/gin-examples/multiple-service$ 

marco@pc01:~/go/pkg/mod/github.com$ ls -lah;
total 40K
drwxrwxr-x 10 marco marco 4.0K Jun 10 15:32 .
drwxrwxr-x  8 marco marco 4.0K May 31 08:40 ..
drwxrwxr-x  5 marco marco 4.0K Jun 10 15:08 gin-contrib
drwxrwxr-x  4 marco marco 4.0K Jun 10 15:08 gin-gonic
drwxrwxr-x  4 marco marco 4.0K Jun 10 15:08 golang
drwxrwxr-x  8 marco marco 4.0K May 31 08:40 gonum
drwxrwxr-x  5 marco marco 4.0K May 31 08:40 hashicorp
drwxrwxr-x  4 marco marco 4.0K Jun 10 15:08 mattn
drwxrwxr-x  3 marco marco 4.0K May 31 08:40 pbnjay
drwxrwxr-x  4 marco marco 4.0K Jun 10 15:32 ugorji

marco@pc01:~/go/pkg/mod/github.com/ugorji$ ls -lah
total 16K
drwxrwxr-x  4 marco marco 4.0K Jun 10 15:32 .
drwxrwxr-x 10 marco marco 4.0K Jun 10 15:32 ..
drwxrwxr-x  3 marco marco 4.0K Jun 10 15:32 go
dr-x------  3 marco marco 4.0K Jun 10 15:32 [email protected]

I realized that this happens for all examples.

How to solve the problem?

@thinkerou
Copy link
Member

gin version?
please see gin-gonic/gin#1673 thanks!

@marcoippolito
Copy link
Author

@thinkerou const Version = "v1.4.0-dev"

As suggested here: https://github.com/ugorji/go/commit/8fd0f8d918c8f0b52d0af210a812ba882cc31a1e
I tried also to add v1.1.2. But the problem persists.
Is there an official solution to the problem? As far as I understand from various discussions, as this one: https://github.com/ugorji/go/commit/8fd0f8d918c8f0b52d0af210a812ba882cc31a1e , there have been different attempts of solution, but none "the" solution. Am I right?

@thinkerou
Copy link
Member

@marcoippolito please use v1.4.0

@marcoippolito
Copy link
Author

marcoippolito commented Jun 11, 2019

@thinkerou After removing also from cache everything related to the previous installation of gin, I repeated the installation:

marco@pc01:~/go/src$ go get -u github.com/gin-gonic/gin
marco@pc01:~$ cat go/src/github.com/gin-gonic/gin/version.go 
// Copyright 2018 Gin Core Team.  All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

// Version is the current gin framework's version.
const Version = "v1.4.0-dev"


marco@pc01:~/go/src/github.com$ go version
go version go1.12.5 linux/amd64

Ubuntu 18.04.01 

What am I doing wrong?
PS: even without the -u flag the version installed is v1.4.0-dev :

marco@pc01:~/go$ go get github.com/gin-gonic/gin

marco@pc01:~$ cat go/src/github.com/gin-gonic/gin/version.go 
// Copyright 2018 Gin Core Team.  All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin

// Version is the current gin framework's version.
const Version = "v1.4.0-dev"

@thinkerou
Copy link
Member

@marcoippolito
Copy link
Author

marcoippolito commented Jun 11, 2019

@thinkerou go.mod is already set as v.1.4.0 :

marco@pc01:~$ cat go/marcoGolang/gin-examples/go.mod
module github.com/gin-gonic/examples

go 1.12

require (
    github.com/dustin/go-broadcast v0.0.0-20171205050544-f664265f5a66
    github.com/gin-gonic/autotls v0.0.0-20190406003154-fb31fc47f521
    github.com/gin-gonic/gin v1.4.0
    github.com/golang/protobuf v1.3.1
    github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
    github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227
    github.com/newrelic/go-agent v2.7.0+incompatible
    github.com/stretchr/testify v1.3.0
    github.com/thinkerou/favicon v0.1.0
    github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43
    golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
    golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
    gopkg.in/go-playground/validator.v8 v8.18.2
)

A) Which other go.mod needs to be changed?

Still do not understand why, following these instructions : https://github.com/gin-gonic/gin#installation ,

B) when installing through:

 go get -u github.com/gin-gonic/gin

v1.4.0-dev is installed. Can you please clarify me also this point?

@thinkerou
Copy link
Member

thinkerou commented Jun 11, 2019

@marcoippolito please learn go mod usage.
If you use gin v1.4.0 release version, github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43 should not exist.

@marcoippolito
Copy link
Author

I discovered that the problem disappears when I download the single example files, one by one, instead of downloading or go-getting the entire examples directory

@mfaerevaag
Copy link

This seemed to fix it for me: gin-gonic/gin#1673 (comment)

@appleboy
Copy link
Member

appleboy commented Nov 29, 2019

Please clone the latest version and try the following steps:

gin version: v1.5
go version: 1.13

# in examples folder
$ go mod download
$ go run multiple-service/main.go

or switch to multiple-service folder

$ go mod init example
$ go mod tidy
$ go run main.go

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