Closed
Description
Let's say we have a repository containing three packages and
we decided to organize them in separate modules for some reasons.
The purple package imports blue and red packages.
> cd $WORKSPACE/example.com/purple > tree . ├── blue │ ├── blue.go │ └── go.mod ├── go.mod ├── purple.go └── red ├── go.mod └── red.go
We created go.mod files in each package directory using 'go mod init example.com/purple/red', etc.
Now we try to build the purple package.
$ go build all go: import "example.com/purple" -> import "example.com/purple/blue": cannot find module providing package example.com/purple/blue go: import "example.com/purple" -> import "example.com/purple/red": cannot find module providing package example.com/purple/red
What's happening underneath is, the go build
command queries https://example.com/purple/red?go-get=1
, ... to get the meta tags. That means, until I check in the packages and go.mod files to the remote repository and make them accessible, I can't build/test.
What's the easiest way to start a multi-module repo with inter-dependency?