#Dagger Module structure (Go workspaces)

1 messages · Page 1 of 1 (latest)

gentle coral
#

Hi,

I've developed a Dagger Module that I'd like to try locally from another Go project (i.e.invoke the module from another project without having to publish the module). I'm trying to use Go workspaces as per the official docs (https://docs.dagger.io/manuals/developer/go/882081/module-structure#go-workspaces) but I can't get it to work.

The directory structure of my project is as follows:

repo

  • cmd (The entry point, contains a main.go and go.mod).
  • ci (Dagger Module, contains dagger.json, go.mod, etc.)
  • go.work (Uses ./ci and ./cmd)

Is there an example of how to use a Dagger Module and a go.work file? Thanks in advance!

It's essential to understand a few key concepts about Dagger Modules created for use with the Go SDK, for a better fit with your normal development workflow.

winter hearth
#

Hey!

Is cmd/main.go also a dagger module, or is it regular go program?

If the latter, this is not fully supported right now, this issue will resolve it.

https://github.com/dagger/dagger/issues/5993

You can call a module from another module without needing to publish anything, but its not possible to call a module from a non-module in any reasonable way yet.

GitHub

Right now if you want to call functions available in a module, the only reasonable ways are from another module or from the CLI. Otherwise you are on your own to load the module and construct graph...

gentle coral
#

Thanks again, @winter hearth ! Yes, it's the latter case the one I'm facing unfortunately.

I have a module which holds several functions to build, test and lint a Go project. My plan was to create a pipeline as another Go program which orchestrates the invocation of those functions.

I guess the only alternative left would be to:

  1. Publish the module to the Daggerverse.
  2. Write a GH workflow that uses dagger call [build|test|lint] ... to define my pipeline.

Is that correct? Is there a way without having to publish the module (yet)? I'd be interested in seeing how other people perform the invokations of their own modules.