P
P
Pryby2021-04-06 18:23:59
go
Pryby, 2021-04-06 18:23:59

Tests and gopath not working, how to fix?

It pulls up the paths, 606c7bdd67407734459376.png
but when importing, it writes an error that
606c7c189d8f2625719544.png
gopath is not found, 606c7c4af28a3509524608.png
why is it not pulling up? I can not understand.

For some reason, the tests do not work, when you click on the method name, alt + enter does not offer anything, like it should suggest creating a test. If you create a file with your hands, it swears at startup, found that you need to check the box, but it did not help.
606c7cb5d46a2429969899.png
this is what it says when i run the test
606c7d0a2e7a0443468356.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Maslov, 2021-04-06
@s0xzwasd

Disable GOPATH integration (File | Settings | GOPATH | Index entire GOPATH), initialize a new go.mod file (go mod init at the root of the project) and then go to import, press Alt+Enter and the Sync Dependencies button should appear.
After that, the dependencies will be added to the go.mod file and will be successfully resolved.
I advise you not to use the GOPATH approach anymore, because in future versions of Go it will already go as deprecated.
PS if you will be using Go Modules and want to import a local project, then I recommend to refer to this article: https://golangbyexample.com/import-local-module-golang/
PSS the best explanation of how it all works is in the official documentation: https:/ /golang.org/doc/code#Workspaces

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question