gin-gonic/gin

use gin v1.4.0 build error ambiguous import

HZ89 opened this issue · 9 comments

HZ89 commented
  • With issues:

    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.
  • go version: 1.12.5

  • gin version (or commit ref):

    github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=
    github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
    
  • operating system: ubuntu 18.04

Description

When I update gin to v1.4.0 build error:

build myproject: 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/harrison/Dropbox/project/go_path/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
        github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 (/home/harrison/Dropbox/project/go_path/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20190320090025-2dc34c0b8780)
Makefile:15: recipe for target 'server' failed

I google this error got this ugorji/go#279

Screenshots

@HZ89 What was your fix?

HZ89 commented

@bvisness
add this to go.mod file. but I think it should be added to go.mod of gin, not my project

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

gin v1.4.0 have updated the package https://github.com/gin-gonic/gin/blob/v1.4.0/go.mod

yes, but use this go.mod, go mod tidy will get an ambiguous import.

vacoo commented

@HZ89 thanks! this is solve my problem

Hi folks,

Please see ugorji/go#299 and add your thoughts/ideas/etc. Thanks.

why cannot just remove "github.com/ugorji/go v1.1.4"?

FYI: I just released a go-codec production release - version 1.1.7 (finally)

First, it resolves the go.mod impasse where we had different import paths (github.com/ugorji/go and github.com/ugorji/go/codec) causing the ambiguous import error.

This is now fixed by leveraging import cycles to ensure that either one works well and resolves to the same bits.

Please let me know if seeing any issues. If all is well over the next few days, I will close this github issue.