#Initializing a new Dagger module on an existing Go project fails (DaggerGo SDK)

1 messages ยท Page 1 of 1 (latest)

analog heart
#

Hello.

When running dagger init --name=my-module --sdk=go on an existing Go project I get the error below.

Running dagger init and then dagger develop --sdk=go returns the same error.

Dagger info: dagger v0.11.0 (registry.dagger.io/engine) darwin/amd64

Thanks!


Stdout:
generating go module: fr-cli
writing dagger.gen.go
creating directory internal
creating directory internal/dagger
writing internal/dagger/dagger.gen.go
creating directory internal/querybuilder
writing internal/querybuilder/marshal.go
writing internal/querybuilder/querybuilder.go
creating directory internal/telemetry
writing internal/telemetry/attrs.go
writing internal/telemetry/batch_processor.go
writing internal/telemetry/init.go
writing internal/telemetry/processor.go
writing internal/telemetry/proxy.go
writing internal/telemetry/span.go
writing main.go
running post-command: go mod tidy
needs another pass...
Stderr:
Error: generate code: template: alias.go.tmpl:74:3: executing "_dagger.gen.go/alias.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: cannot find default codegen DaggerObject interface```
naive finch
naive finch
lapis merlin
analog heart
#

Hey folks, thanks for looking into this.
@naive finch My go.mod is set to go 1.22.2
After reading the thread in that GitHub issue I'm not sure how to fix or work around the issue though.

#

Will dagger init --name=my-module --sdk=go only work with go 1.21 at this stage?

#

For the record, I have run dagger init --name=my-module --sdk=go in an empty directory and then copied the generated files over the Go repo (v1.22.2) I want to use dagger in. Dagger seems to be working fine so far ๐Ÿ‘ If you this approach may cause any issues down the road, please let me know.

It would be great if dagger init worked fine in Golang repos running the latest stable version.

lapis merlin
#

I've tried to repro but I wasn't able. Here's what I did:

130|marcos:tmp/test3 (โŽˆ |N/A)$ go mod init test3
go: creating new go.mod: module test3
marcos:tmp/test3 (โŽˆ |N/A)$ de^C
130|marcos:tmp/test3 (โŽˆ |N/A)$ ls
go.mod
marcos:tmp/test3 (โŽˆ |N/A)$ de^C
130|marcos:tmp/test3 (โŽˆ |N/A)$ dagger init --sdk go
10:19:55 WRN no LICENSE file found; generating one for you, feel free to change or remove license=Apache-2.0
Initialized module test3 in .
marcos:tmp/test3 (โŽˆ |N/A)$ ^C
130|marcos:tmp/test3 (โŽˆ |N/A)$ dagger functions
Name             Description
container-echo   Returns a container that echoes whatever string argument is provided
grep-dir         Returns lines that match a pattern in the files of the provided Directory
marcos:tmp/test3 (โŽˆ |N/A)$

^ as you can see, that works!

broken reef
lapis merlin
#

maybe the OP has somehow incorrectly setup his module that it's triggering #6706?

broken reef
#

if go.mod is set higher than 1.21, then yes, this is the same issue

lapis merlin
#

I'm understanding from this thread that there are two go.mod files. One for the "project", and another for the module

lapis merlin
#

one with 1.22 (project) and another with 1.21 (module)

broken reef
#

multiple go.mods aren't relevant for the issue in this thread i don't think

#

the issue is that you can't have 1.22 being in a go.mod that belongs to a dagger module

#

i think this should have been fixed though? we should be erroring out with a neater message, which is confusing