Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go.mod unresolved dependency

Tags:

heroku

go

i am using 1.14.2 version of go. i am trying to add my project to go.mod to deploy heroku by using go mod init <dependecyname>. After that i try to go run main.go command to run my project but i received following error:

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:

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?

like image 612
Ali Gürelli Avatar asked Oct 21 '20 12:10

Ali Gürelli


People also ask

What is an unresolved dependency?

Unresolved dependencies are those dependencies that are present in the repository, but not in the deployment set. Deployer enables you to add, ignore, or automatically resolve those dependencies.

How do I sync Go dependencies?

Synchronize dependencies from the opened Go fileClick a dependency in the import section, press Alt+Enter and select Sync dependencies.

How do I add a dependency in Golang?

sum file with the checksum and version of all direct and indirect dependencies. go build as well as go install also will download the dependencies and also build the binary. go run will also download and and run the binary as well. go mod download command is used when you want to pre download the dependencies without ...

What is Go mod tidy?

go mod tidy ensures that the go. mod file matches the source code in the module. It adds any missing module requirements necessary to build the current module's packages and dependencies, if there are some not used dependencies go mod tidy will remove those from go.


1 Answers

I had the similar issue and I was able resolve by enabling the go modules integration. You can do that from Preferences > GO > GO Modules.

like image 200
Gopi Podila Avatar answered Sep 27 '22 17:09

Gopi Podila