Go get breaks on internal packages installation

Hi, I have a problem with one of my projects.
The structure is the following:

├── cmd
│   └── stuff.go
├── Gopkg.lock
├── Gopkg.toml
├── internal
│   ├── myinternalpackage
│   │   ├── myinternalpackage.go

building the project with go build cmd/stuff.go everything is working perfectly, the problem comes when i have to go get it from my repository

go get -v github.com/myrepo/myproject/cmd
../../myrepo/myproject/cmd/stuff.go:6:2: use of internal package not allowed

the content of stuff.go is

...
import (
   "fmt"
   "github.com/myrepo/myproject/internal/myinternalpackage" #this is where it errored
)
...

My guess would be that “github.com/myrepo/myproject” is not actually the same in both cases, for example differing in letter case. Show us the the actual command and actual output if this is not the case, not just your fake placeholders.

1 Like

Shouldn’t it be go get -v github.com/myrepo/myproject? Try to import internal package using relative path.

No, since in the root project there are not go files

You are totally right, it was just a simple typo, I fixed it and moved the go file in cmd/stuff/main.go thengo get github.com/me/myrepo/stuff` and everything worked fine

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.