Go Workspace
Developing two separate repos together using go.work.
Scenario: You have a bookmarks API and a shared library (gokit) in separate repos. You need to edit both at the same time.
projects/
├── go.work ← NOT committed to version control
├── bookmarks/
│ ├── go.mod ← module: github.com/yourname/bookmarks
│ └── main.go
└── gokit/
├── go.mod ← module: github.com/yourname/gokit
├── errx/
│ └── errx.go
└── slogr/
└── slogr.gogo.work file:
go 1.24
use (
./bookmarks
./gokit
)Setup:
cd projects
go work init
go work use ./bookmarks ./gokitbookmarks/go.mod stays clean — normal require, no replace:
module github.com/yourname/bookmarks
go 1.24
require github.com/yourname/gokit v0.2.0The workspace silently redirects github.com/yourname/gokit to the local ./gokit directory. When done developing:
# Tag and push gokit
cd gokit && git tag v0.3.0 && git push --tags
# Update bookmarks to use the published version
cd ../bookmarks && go get github.com/yourname/[email protected]
# CI uses GOWORK=off to test against published versions
GOWORK=off go test ./...