Here’s my recommended project structure in that case It is just a convention to put all exported code in pkg |- internal - most code should go here by default, code here cannot be accessed outside of pkg1 |- cmd - CLI tools or web server startup code goes here To add that mapping just use the replace directive and add the following to src/pkg2/go.mod .