go-microservice
and validating Go-based microservices in CI/CD workflows.This module was scaffolded using `dagger init` and designed to serve as a flexible
DevOps automation unit for Go projects. It integrates static analysis, unit testing,
code coverage reporting, and security scanning in a streamlined containerized pipeline.
The primary function orchestrates the workflow by accepting source directories,
test file paths, linter configurations, and other runtime options. It ensures
clean and consistent execution environments for Go toolchain operations using Dagger
containers and caches.
Features include:
- Static analysis using golangci-lint with customizable configuration
- Unit test execution with optional code coverage reports
- Modular and composable design, suitable for use in monorepos or multi-service platforms
- Security scanning with tools like `gosec` (planned)
This module can be invoked via the Dagger CLI or imported into another Dagger pipeline,
making it ideal for use in CI runners, GitOps systems, or developer workstations.
Future improvements may include:
- Dependency vulnerability scanning integration (e.g., `govulncheck` or `trivy`)
- Auto-formatting and import validation (`goimports`, `gofmt`)
- Multi-platform build support for releasing binaries
- Integration with release pipelines for tagging, changelogs, and artifact publishing
This documentation serves as both an overview and implementation reference
for integrating Go microservice workflows using Dagger.
Installation
dagger install github.com/stuttgart-things/blueprints/go-microservice@v1.19.0Entrypoint
Return Type
GoMicroservice Example
dagger -m github.com/stuttgart-things/blueprints/go-microservice@175f221684391b3fca8c4421ec66137bc64ae7ab call \
func (m *MyModule) Example() *dagger.GoMicroservice {
return dag.
GoMicroservice()
}@function
def example() -> dagger.GoMicroservice:
return (
dag.go_microservice()
)@func()
example(): GoMicroservice {
return dag
.goMicroservice()
}Types
GoMicroservice 🔗
runStaticStage() 🔗
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | No description provided |
| lintTimeout | String | "500s" | No description provided |
| goVersion | String | "1.24.4" | No description provided |
| os | String | "linux" | No description provided |
| arch | String | "amd64" | No description provided |
| goMainFile | String | "main.go" | No description provided |
| binName | String | "main" | No description provided |
| ldflags | String | - | No description provided |
| lintCanFail | Boolean | "false" | No description provided |
| testArg | String | "./..." | No description provided |
| lintEnabled | Boolean | true | No description provided |
| test | Boolean | true | No description provided |
Example
dagger -m github.com/stuttgart-things/blueprints/go-microservice@175f221684391b3fca8c4421ec66137bc64ae7ab call \
run-static-stage --src DIR_PATHfunc (m *MyModule) Example(src *dagger.Directory) *dagger.File {
return dag.
GoMicroservice().
RunStaticStage(src)
}@function
def example(src: dagger.Directory) -> dagger.File:
return (
dag.go_microservice()
.run_static_stage(src)
)@func()
example(src: Directory): File {
return dag
.goMicroservice()
.runStaticStage(src)
}runBuildStage() 🔗
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | No description provided |
| goVersion | String | "1.24.3" | No description provided |
| os | String | "linux" | No description provided |
| arch | String | "amd64" | No description provided |
| goMainFile | String | "main.go" | No description provided |
| binName | String | "main" | No description provided |
| ldflags | String | - | No description provided |
| tokenName | String | "GITHUB_TOKEN" | No description provided |
| packageName | String | "" | No description provided |
| token | Secret | - | No description provided |
| koRepo | String | "ko.local" | No description provided |
| koVersion | String | "v0.18.0" | No description provided |
| koBuildArg | String | "." | No description provided |
| koPush | String | "false" | No description provided |
| buildBinary | Boolean | true | No description provided |
| koBuild | Boolean | true | No description provided |
| reportName | String | "build-report.txt" | No description provided |
Example
dagger -m github.com/stuttgart-things/blueprints/go-microservice@175f221684391b3fca8c4421ec66137bc64ae7ab call \
run-build-stage --src DIR_PATHfunc (m *MyModule) Example(src *dagger.Directory) *dagger.Directory {
return dag.
GoMicroservice().
RunBuildStage(src)
}@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.go_microservice()
.run_build_stage(src)
)@func()
example(src: Directory): Directory {
return dag
.goMicroservice()
.runBuildStage(src)
}