I am using go modules in my project. I have shared code in the internal folder.
.
├── README.md
├── internal
│ └── shared
│ ├── request.go
│ └── request_test.go
└── web
├── README.md
└── go
└── src
└── webservice
├── go.mod
├── go.sum
└── main.go
I am not able to access the internal/shared from webservice while using go modules. I get the following error:
package internal/shared is not in GOROOT (/usr/local/go/src/internal/shared)
While importing from webservice in main.go:
import "internal/shared"
Note: I am trying to share internal/shared with another mod that is not listed above.
How to fix this issue?
internal
isn't part of thewebservice
module. Either moveinternal
into the correct location, or make the entire project a single module. The code layout is quite unusual, is there a reason it's structured in this way? – Canella