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

GO111MODULE run error #1737

Closed
shenxinbo opened this issue Jan 9, 2019 · 3 comments
Closed

GO111MODULE run error #1737

shenxinbo opened this issue Jan 9, 2019 · 3 comments

Comments

@shenxinbo
Copy link

shenxinbo commented Jan 9, 2019

for basic demo

package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	r.Run() // listen and serve on 0.0.0.0:8080
}

if I run
go run main.go

the error is
../../../golang/pkg/mod/github.com/gin-gonic/[email protected]/binding/msgpack.go:12:2: ../../../golang/pkg/mod/github.com/ugorji/go/[email protected]/goversion_vendor_eq_go15.go:1:1: expected 'package', found 'EOF'

go version 1.11.4 with GO111MODULE=on

@jmortonTarget05
Copy link

jmortonTarget05 commented Jan 15, 2019

Has there been any investigation or workaround identified?
My error is similar, but not exact. gin import appears to pull in 2 references for github.com/ugorji/codec:

/go/pkg/mod/github.com/gin-gonic/[email protected]/binding/msgpack.go:12:2: unknown import path "github.com/ugorji/go/codec": ambiguous import: found github.com/ugorji/go/codec in multiple modules:
	github.com/ugorji/go v1.1.1 (/go/pkg/mod/github.com/ugorji/[email protected]/codec)
	github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/go/pkg/mod/github.com/ugorji/go/[email protected])

@markhomoki
Copy link

I'm having the same issue, any thoughts?

@zaynetro
Copy link
Contributor

Did you init go.mod file?

The following steps to run the project produce no errors:

$ mkdir gin-modules

$ cd gin-modules/

$ cat > main.go
package main

import "github.com/gin-gonic/gin"

func main() {
  r := gin.Default()
  r.GET("/ping", func(c *gin.Context) {
    c.JSON(200, gin.H{
      "message": "pong",
    })
  })
  r.Run() // listen and serve on 0.0.0.0:8080
}
^D

$ export GO111MODULE=on

$ go mod init .
go: creating new go.mod: module .

$ go run main.go
go: finding github.com/gin-contrib/sse latest
go: finding github.com/ugorji/go/codec latest
go: finding github.com/golang/protobuf/proto latest
go: finding gopkg.in/yaml.v2 v2.2.2
go: downloading github.com/gin-contrib/sse v0.0.0-20190124093953-61b50c2ef482
go: downloading github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2
go: downloading gopkg.in/yaml.v2 v2.2.2
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /ping                     --> main.main.func1 (3 handlers)
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080
^Csignal: interrupt

$ go version
go version go1.11.4 darwin/amd64

appleboy pushed a commit that referenced this issue Jan 25, 2019
#1604 #1566 #1700 #1737 

because some dependencies only are used on example i.e. grpc.

Or migrate `examples` to gin-gonic/examples`?
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

5 participants