Skip to content

Put the go.mod file at the root of the repo. Have only one module per repo.

License

Notifications You must be signed in to change notification settings

tullo/nested-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nested Modules

Shows how you can use one repository for nested modules written on Go. Each submodule has unique tag,

git clone git@github.com:tullo/nested-modules.git
cd nested-modules
git tag -l
# app/v0.0.2
# lib/v0.0.1

Start example app

go get github.com/tullo/nested-modules/lib
go run app/main.go 
08:57:12

General Best Practice

The general best practice is to put your go.mod file at the root of the repo, and have only one module per repo. Then all of the packages within the repo will be in the same module and share the same dependencies.

It is possible to define multiple modules within a single repository, but doing so adds a lot of maintenance overhead: if you have multiple modules, they are treated as completely separate; you have to explicitly manage the dependencies between them, and you have to explicitly tag separate releases for them.

For most projects, that extra overhead comes with very little benefit

See also Code organization

About

Put the go.mod file at the root of the repo. Have only one module per repo.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages