go modules - ghdrako/doc_snipets GitHub Wiki
- https://stackoverflow.com/questions/61845013/package-xxx-is-not-in-goroot-when-building-a-go-project
- https://zetcode.com/golang/module/
- https://go.dev/doc/tutorial/create-module
go mod init example.com/greetings
The go tool provides several commands that are related to modules.
go mod init
- initializes new module in current directorygo mod tidy
- adds missing and removes unused modulesgo mod download
- downloads modules to local cachego mod vendor
- makes vendored copy of dependenciesgo mod graph
- prints module requirement graphgo mod verify
- verifies dependencies have expected contentgo mod why
- explains why packages or modules are needed
There are additional commands related to Go modules.
The go list -m
lists available modules. The go get installs dependencies and updates the go.mod
file. The go build
and go test
commands add new dependencies to go.mod
as needed.
- https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/ The problem is because you have not publish your module to a central location like github. You have to run this command to tell go that the module is a local module
go mod edit --replace external_folder_module_name= ../pathItsLocated
$ go mod edit -replace github.com/pselle/bar=/Users/pselle/Projects/bar