Gin 中使用gormt将mysql数据库自动生成gorm结构体后:

1
2
go get -u -v github.com/xxjwxc/gormt@master
gormt -H=127.0.0.1 -d=oauth_db -p=qwer -u=root --port=3306

再此运行Gin时会报

1
2
3
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 (/Users/tonytan/go/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/Users/tonytan/go/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181209151446-772ced7fd4c2)

错误.

报错的字面意思是有一个包多个地方引用但版本不一致。

网上查询找到解决方法,详见 https://github.com/ugorji/go/issues/279。

1.1.2版本修复了该问题

这时需要运行以下命令:

go get github.com/ugorji/go@v1.1.2

已安装了1.1.4,但是还是报错,如果安装1.1.2,则能解决改问题