I have a Go project with a structure like this:
cmd
myapp
main.go
internal
app
myapp
impl.go
Now in main.go
, I want to import impl.go
. GoLand tells me that I should do it like this:
import (
"myproj/internal/app/myapp"
)
However, I compile the project on another machine (because I use EGL and that's not available on macOS). When I do
go build cmd/myapp/main.go
there, it cannot resolve the import. So I changed the import to use the full path of my github repo, like this:
import (
"github.com/flyx/myproj/internal/app/myapp"
)
Code compiles fine now. However, after I pulled that back into GoLand, it cannot resolve the import anymore. Curiously, every item in the path gives a separate error, e.g.
Cannot resolve directory 'github.com'
That's very strange since github.com
is very obviously in my $GOPATH/src
and other imports from there that are not my current project are working.
So… what am I doing wrong? I don't even understand how GoLand can resolve the path starting with myproj
. I checked whether GOPATH
is correctly set in GoLand and that's the case.