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.
In more detail
It solves the tool-plus-library problem: edit a library and the tool that imports it sees the change at once, with no publishing or version bump. It replaces the older habit of adding a temporary replace directive. The file describes your machine, so keep it out of the repository, and set GOWORK=off to check the module builds as a stranger would.
Examples
go work init ./tool ./libGOWORK=off go build ./...Related terms
- Go module — A tree of Go packages that is versioned and released together, described by a go.mod file at its root.
- 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.
- 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
- Installing the Go Toolchain — Concurrent Systems Programming with Go
- Go Workspaces and Modules — Concurrent Systems Programming with Go