Part of dagger/dagger#13805
Context
Each generated client is its own Go module. That is deliberate: it lets the client state the dagger.io/dagger version it needs without changing what the rest of the project resolves to.
If we write a go.mod into someone's project, we own it, and it should meet the same standard as any other go.mod there. It should build, and it should pass CI.
Problem
The generated go.mod is a module line, a go line, and one require:
module engine-dev
go 1.25.12
require dagger.io/dagger v1.0.0-0
No go.sum. go build in that directory fails on missing go.sum entries. Editors treat the directory as a broken module and report errors on every file in it, which is the first thing a user sees after generating a client.
No way to resolve a locally replaced SDK. Go ignores replace directives from anything but the main module, so a parent that replaces dagger.io/dagger with a local path is invisible here. Anyone working inside a checkout of the SDK cannot build the client on its own at all.
Solution
- write a
go.sum
- if the parent
go.mod replaces dagger.io/dagger, copy the replace in, with the path rebased on the client's location
Regeneration already preserves an existing go.mod, so both can be fixed by hand today and will survive. That is a workaround, not the fix.
The go.mod is written in generate_client.go, freshClientGoMod.
Part of dagger/dagger#13805
Context
Each generated client is its own Go module. That is deliberate: it lets the client state the
dagger.io/daggerversion it needs without changing what the rest of the project resolves to.If we write a
go.modinto someone's project, we own it, and it should meet the same standard as any othergo.modthere. It should build, and it should pass CI.Problem
The generated
go.modis a module line, a go line, and one require:No
go.sum.go buildin that directory fails on missinggo.sumentries. Editors treat the directory as a broken module and report errors on every file in it, which is the first thing a user sees after generating a client.No way to resolve a locally replaced SDK. Go ignores replace directives from anything but the main module, so a parent that replaces
dagger.io/daggerwith a local path is invisible here. Anyone working inside a checkout of the SDK cannot build the client on its own at all.Solution
go.sumgo.modreplacesdagger.io/dagger, copy the replace in, with the path rebased on the client's locationRegeneration already preserves an existing
go.mod, so both can be fixed by hand today and will survive. That is a workaround, not the fix.The
go.modis written in generate_client.go,freshClientGoMod.