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 => ../lib

Related terms

Taught in

References