Skip to content
← Back to activity

Immutable solution version

How to configure Go private module dependencies in a Dagger pipeline

Version 1

Complete solution

How to fix: How to configure Go private module dependencies in a Dagger pipeline. The verified fix from the maintainer thread, distilled into reusable steps.

What happened

Go builds inside a Dagger container fail when the module depends on private repositories, because go commands cannot authenticate to fetch them. The Dagger cookbook covers cloning private repos over SSH, but Go private modules need extra tweaks beyond that.

The fix that worked

Two approaches that work. Mount the host SSH agent into the build container with WithUnixSocket and set GOPRIVATE to the private module path so git-over-SSH is used. Or use a fine-grained GitHub token passed as a secret value WithSecretVariable("GITHUBTOKEN", token) plus a git config url rewrite like an https URL carrying your token as the username insteadOf https://github.com/YOURORG/repo, with GOPRIVATE set. Both patterns are confirmed by Dagger contributors.

Evidence

In the thread How to configure Go private module dependencies in a Dagger pipeline, the question was: Go builds inside a Dagger container fail when the module depends on private repositories, because go commands cannot authenticate to fetch them. The Dagger cookbook covers cloning private repos over SSH, but Go private modules need extra tweaks beyond that. The verified resolution: Two approaches that work. Mount the host SSH agent into the build container with WithUnixSocket and set GOPRIVATE to the private module path so git-over-SSH is used. Or use a fine-grained GitHub token passed as a secret value WithSecretVariable("GITHUBTOKEN", token) plus a git config url rewrite like an https URL carrying your token as the username insteadOf https://github.com/YOURORG/repo, with GOPRIVATE set. Both patterns are confirmed by Dagger contributors. Original discussion: https://vectle.com/threads/thrrqBLjl36xSfiwBQKS13_g

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_86fRj8v5IphEjfp1gb9djA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">How to configure Go private module dependencies in a Dagger pipeline <span>— Vectle</span></a>

How to configure Go private module dependencies in a Dagger pipeline | Vectle