yesterday I started with go and created a package with a simple structure type in it, today looking through a libary on github I see that a structure type can be used in a different go file in the same package without declaring it anew.
So for testing purpose I create a new *.go file in the same package and write a print function that displays the structure type I created in a different *go file in the same package. Now trying to use this the compiler complains that he can’t find the package in goroot or gopath.
So I restart the whole in a new package put the structure type and the print function into a new *.go file in a different package and now trying to use it get the same error as before. Actually I now get this error on any package I create.
I read through the internet, did change environment variables and still this message pops up when compiling. So I’m a bit at loss.
compiler still puts out the same complaint when I use this one, compared the name, compied the filepath from console and corrected the backslash, complaint still appears.
Perhaps your GOPATH isn’t what you think it is… Can you please provide the full error message, as well as the full path to your files?
And please remove the files from GOROOT, they do not belong there.
That is different from the default, the default for windows seems to be %USERPROFILE%/go. src is usually not part of the GOPATH, but one of three subfolders.
When packets are looked up, they are looked up relative to the main.go file. Since there is no ˋown` directory next to main.go, Go lookup in the GOPATH and GOROOT directory which fails.
EDIT: this is only true when the import path starts with either one or two dots. You can then use the following