[英]go.mod unresolved dependency
i am using 1.14.2 version of go.我使用的是1.14.2版本的 go。 i am trying to add my project to go.mod
to deploy heroku by using go mod init <dependecyname>
.我正在尝试使用go mod init <dependecyname>
将我的项目添加到go.mod
以部署heroku 。 After that i try to go run main.go
command to run my project but i received following error:之后,我尝试go run main.go
命令来运行我的项目,但收到以下错误:
go: finding module for package github.com/googollee/go-socket.io
go: finding module for package github.com/dgrijalva/jwt-go
go: finding module for package github.com/gorilla/mux
go: found github.com/dgrijalva/jwt-go in github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: found github.com/googollee/go-socket.io in github.com/googollee/go-socket.io v1.4.4
go: found github.com/gorilla/mux in github.com/gorilla/mux v1.8.0
controllers/userController.go:10:2: cannot find package
models/avatar.go:3:8: cannot find package
models/base.go:6:1: cannot find package
models/base.go:7:1: cannot find package
models/user.go:8:2: cannot find package
controllers/userController.go:11:2: cannot find package
controllers/userController.go:12:2: cannot find package
controllers/userController.go:13:2: cannot find package
and also when i investigate my go.mod
file then i realized that there is unresolved dependency error in require
block:而且当我调查我的go.mod
文件时,我意识到require
块中有未解决的依赖错误:
module <modulename>
go 1.14
require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/googollee/go-socket.io v1.4.4 // indirect
github.com/gorilla/mux v1.8.0 // indirect
)
how to fix it?如何解决?
I had the similar issue and I was able resolve by enabling the go modules integration.我遇到了类似的问题,我能够通过启用 go modules 集成来解决。 You can do that from Preferences > GO > GO Modules.您可以从 Preferences > GO > GO Modules 执行此操作。
The go init
command initializes the go module for the current project by adding a new go.mod
file to your root folder with the module name you specified. go init
命令通过使用您指定的模块名称将新的go.mod
文件添加到您的根文件夹来初始化当前项目的 go 模块。 To add new dependencies to your project, use go get <path>
and after that, it should be listed in the go.mod
file.要将新的依赖项添加到您的项目中,请使用go get <path>
之后,它应该列在go.mod
文件中。
I was able resolve this issue by turn off and on the go modules integration.我能够通过关闭和运行模块集成来解决这个问题。 GOLANG Preferences > GO > GO Modules. GOLANG 首选项 > GO > GO 模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.