replace directive
A line in go.mod that tells the go command to use a different copy of a module, often a folder on your disk, instead of the published version.
In more detail
It is useful for testing a local fix to a dependency. The risk is forgetting to remove it before committing, which breaks the build for everyone else. A Go workspace does the same job without editing go.mod.
Example
replace course.local/lib => ../libRelated terms
- Go workspace — A go.work file that tells the go command to build several local modules together from your disk instead of from their published versions.
- go.mod — The text file at the root of a Go module that records its module path, the Go version it needs and the other modules it depends on.
Taught in
- Go Workspaces and Modules — Concurrent Systems Programming with Go