Skip to main content

IDE Integration

Dagger uses GraphQL as its low-level language-agnostic API query language, and each Dagger SDK generates native code-bindings for all dependencies from this API. This gives you all the benefits of type-checking, code completion and other IDE features for your favorite language when developing Dagger Functions.

The dagger develop command bootstraps a Dagger module template in the selected programming language and sets up or updates all the resources needed to develop a module. After running this command, follow the steps below to have your IDE recognize the Dagger module.

To get your IDE to recognize a Dagger Go module, configure your go.work file to include the path to your module.

When you generate a Dagger module for the first time, Dagger will create a go.mod file just for the module. If the module exists in a sub-directory of an outer Go project (such as dagger/, the default), this might confuse the IDE.

If there is already a go.mod in the parent directory that you would like to use instead, delete the newly-generated go.mod and go.sum and Dagger will use the parent one instead. This is not advisable if your Dagger module has certain dependencies that are not relevant to your core product, since most consumers will prefer a narrower set of dependencies.

To keep the generated go.mod file and edit your Dagger module in the same IDE session as your project code, one option is to set up a Go workspace:

# in the root of your repository
go work init
go work use ./
go work use ./path/to/mod

After restarting the IDE, you should be able to use IDE features such as go-to-definition, even when editing dagger/main.go from the project root.

In most cases, go.work should not be committed to the repository, so it is advisable to add it to the project's .gitignore file:

echo go.work >> .gitignore
echo go.work.sum >> .gitignore
tip

You can also choose to omit the local Go files generated by dagger develop from your version control system, as they aren't required to run the module.