Using subpackages with go mod locally
For another approach, you can have go.mod
like this:
module awesome
Then call subpackage like this:
import "awesome/subpackageA"
https://golang.org/doc/code.html
Go has no (real) notion of "subpackage". All packages are basically treated equal. This means that a replace bitbucket.org/me/awesome
does not influence package bitbucket.org/me/awesome/subpackageA
as these are two individual, unrelated packages. The folder layout does not introduce a relation of subpackageA to awsome, or the other way around *).
So you need to add an individual replace directive for subpackageA
replace bitbucket.org/me/awesome/subpackageA => ./subpackageA
*) Nitpicking for absolute correctness: Folder layout does have influence for folders named internal
(cannot be imported from other projects), for folders named vendor
(which may contain vendored packages) and searching for a go.mod
file stops at the repo root.