'cannot find package from goroot gopath
if i download external library (ex. go get -u github.com/gin-gonic/gin)
it goes to c:\Users\username\go\pkg\mod not c:\Users\username\go\src
Inside the go\pkg\mod folder, it has external library
i got error like this
could not import github.com/gin-gonic/gin (cannot find package "github.com/gin-gonic/gin" in any of
C:\Program Files\Go\src\github.com\gin-gonic\gin (from $GOROOT)
C:\Users\dusrj\go\src\github.com\gin-gonic\gin (from $GOPATH))
My GOPATH & GOROOT is as follows
go env GOPATH
-> C:\Users\dusrj\go
go env GOROOT
-> C:\Program Files\Go
If I manipulate environment variables in the system window and change GOPATH to the following,
C:\Users\dusrj\go\pkg\mod
error message is changed like this
could not import ...
...omitted...
C:\Users\dusrj\go\pkg\mod\src\github.com\gin-gonic\gin (from $GOPATH))
The weird thing is that sometimes there is no error
Creating an src folder in a C:\Users\dusr\go path and copying and pasting the github folder in it didn't worked for me
go mod init also didn't worked for me
OS: Window10, Go version: 1.17.6 IDE: vsocde
Any help would be highly appreciated. thank U :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
