You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When initializing a new dagger module with the Go SDK, by default no go.mod is created if a parent go.mod already exists. This is not the correct default behavior. It causes confusion, and in some cases can even break development altogether.
As a rule of thumb: by default, my dagger module should be an island. It should work the same regardless of what else is going on in the same repo. If I want my module's behavior to depend on another part of the repo, that should be expressed as a dagger dependency in my dagger.json.
Solution
Change the default behavior of the Go SDK, to not reuse a parent go.mod. Initializing a dagger module in Go should always result in also initializing a new go module, by default
Reacted by Nipuna Perera, Ivan Velichko, Drewry Pope, Alex Suraci, Florian Forster, cndoit18, Eric Lee, depado and Vincent Maffet
For those playing along at home, I worked around this in a primitive way: move the go mod/sum out of the way and initialize without them in the root of the repo
Activity
elee commentedon Jul 30, 2024
👍 to this as I'm bumping up against it introducing Dagger to a Go project with a pre-existing
go.{mod,sum}marcosnils commentedon Jul 30, 2024
I'm currently working on this one. I'll try to squeeze it before the next release 👐
elee commentedon Jul 30, 2024
For those playing along at home, I worked around this in a primitive way: move the go mod/sum out of the way and initialize without them in the root of the repo
This works I believe because the
go mod tidyissued here just happens to catch our root go mod but not mutate itdagger/cmd/codegen/generator/go/generator.go
Lines 72 to 78 in c544987