Skip to content

The generated go.mod cannot build on its own #20

Description

@shykes

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.

Activity

  1. changed the title [-]The generated go.mod cannot be built on its own[/-] [+]The generated go.mod cannot build on its own[/+] on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions