heroku go.mod未解析的依赖项

uplii1fm  于 2023-03-03  发布在  Go
关注(0)|答案(3)|浏览(218)

我正在使用1.14.2版本的go。我正在尝试将我的项目添加到go.mod以使用go mod init <dependecyname>部署heroku。之后,我尝试使用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

并且在我调查了我的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
)

怎么解决呢?

5sxhfpxr

5sxhfpxr1#

我也遇到过类似的问题,我可以通过启用Go模块集成来解决。您可以从Preferences〉Go〉Go模块中完成此操作。

f4t66c6m

f4t66c6m2#

我可以通过关闭和打开模块集成来解决这个问题。GOLANG首选项〉GO〉GO模块。

hmmo2u0o

hmmo2u0o3#

go init命令初始化当前项目的go模块,方法是在根文件夹中添加一个新的go.mod文件,并使用指定的模块名。要在项目中添加新的依赖项,请使用go get <path>,之后,它应该会列在go.mod文件中。

相关问题