#Side quest I m going to try taking all

1 messages · Page 1 of 1 (latest)

unreal mortar
#

👍 - one trick to figure out is what to name the Go module. I went with vito-mod in my README but the downside is most Go tooling can't distinguish that from stdlib, so if you have any Go packages in your module that you want to import, it'll organize e.g. vito-mod/mypkg with all the stdlib imports, which is funky

exotic scaffold
#

yeah I noticed the go mod init doesn't pick a name, does dagger mod init already inject a go module name?

unreal mortar
#

nope, it's not aware of Go modules at all. in fact our current tests actually run from the outer github.com/dagger/dagger module, which is how they're dodging the go mod replace issue

exotic scaffold
#

ah ok

unreal mortar
#

you could maybe take the git origin and the relative path within the repo, to give you something like github.com/dagger/dagger/zenith/vito-mod as the module name. Tricky though, it'll work easily for GitHub but might not be generalizable

#

oh, maybe you could look for a go.mod in the root of the repo and append to that module name?

#

wonders if any other tooling has already solved this problem

unreal mortar
#

fyi: gonna focus on fixing the go mod replace issue, which will probably require me to figure out the rest of this since you need to know the name of the current module so you can import the local querybuilder package.

exotic scaffold
#

Roger roger

#

I haven't even started on my side quest, so don't worry about conflicts with my imaginary code

unreal mortar
#

this has been 90% done for a while now, but I'm about to give up on automating the go mod tidy part as it's a bit of a quagmire

#

there's no way to do that programmatically, and there's a really awkward circular dependency between the codegen, the initial "stub" main.go it generates, and the go.mod handling

#

so I think the new flow will be cd empty-dir/ => dagger mod init => go mod tidy

exotic scaffold
#

what happens if we just exec go mod tidy ?

unreal mortar
#

that's on the table, sure

exotic scaffold
#

(no good gif for “side quest”)

unreal mortar
#

the awkward thing with go mod tidy is it'll remove any dependencies not referenced by code, but we need to run it before the code is generated, otherwise the codegen process chokes on a confusing error (somehow there's an entry missing from go.sum but this isn't a problem in the real SDK somehow ???)

#

ooo, maybe because sdk/go/go.mod has a replace rule...

#

hmm the simplest thing here might be to just keep a dependency on dagger.io/dagger after all. It'd be a single version that the CLI can just bump to match its version (once we bootstrap)

unreal mortar
#

ok, got something working 🎉