go-dagger
This module has been generated via dagger init and serves as a reference tobasic module structure as you get started with Dagger.
Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.
The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
Installation
dagger install github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61
Entrypoint
Return Type
GoDagger
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
func (m *myModule) example() *GoDagger {
return dag.
GoDagger()
}
@function
def example() -> dag.GoDagger:
return (
dag.go_dagger()
)
@func()
example(): GoDagger {
return dag
.goDagger()
}
Types
GoDagger 🔗
test() 🔗
Test runs the Go tests
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | source is the directory containing the Go source code |
goVersion | String | "1.22.0" | goVersion is the version of Go to use for building the binary |
ignoreCache | Boolean | false | ignoreCache is a flag to ignore the cache |
race | Boolean | false | race is a flag to include Go's built-in data race detector |
verbose | Boolean | false | verbose is a flag to enable verbose output |
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
test --source DIR_PATH
func (m *myModule) example(source *Directory) *Container {
return dag.
GoDagger().
Test(source)
}
@function
def example(source: dagger.Directory) -> dagger.Container:
return (
dag.go_dagger()
.test(source)
)
@func()
example(source: Directory): Container {
return dag
.goDagger()
.test(source)
}
lint() 🔗
Lint runs the Go linter
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | source is the directory containing the Go source code |
golangCilintImage | String | "golangci/golangci-lint:v1.57.2" | golangCILintImage is the container image to use for the linter |
timeout | String | "5m" | timeout is the maximum time to run the linter |
verbose | Boolean | false | verbose is a flag to enable verbose output |
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
lint --source DIR_PATH
func (m *myModule) example(source *Directory) *Container {
return dag.
GoDagger().
Lint(source)
}
@function
def example(source: dagger.Directory) -> dagger.Container:
return (
dag.go_dagger()
.lint(source)
)
@func()
example(source: Directory): Container {
return dag
.goDagger()
.lint(source)
}
build() 🔗
Build builds the Go binary for the specified go version and platforms
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | source is the directory containing the Go source code |
goVersion | String | "1.22.0" | goVersion is the version of Go to use for building the binary |
platforms | [String ! ] | ["linux/amd64", "linux/arm64"] | platforms is the list of platforms to build the binary for |
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
build --source DIR_PATH
func (m *myModule) example(source *Directory) *Directory {
return dag.
GoDagger().
Build(source)
}
@function
def example(source: dagger.Directory) -> dagger.Directory:
return (
dag.go_dagger()
.build(source)
)
@func()
example(source: Directory): Directory {
return dag
.goDagger()
.build(source)
}
dockerBuild() 🔗
DockerBuild packages the Go binary into a container image
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
bin | Directory ! | - | bin is the directory containing the cross-platform Go binaries |
platform | String | - | platform is the platform to build the binary for |
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
docker-build --bin DIR_PATH
func (m *myModule) example(bin *Directory) *Container {
return dag.
GoDagger().
DockerBuild(bin)
}
@function
def example(bin: dagger.Directory) -> dagger.Container:
return (
dag.go_dagger()
.docker_build(bin)
)
@func()
example(bin: Directory): Container {
return dag
.goDagger()
.dockerBuild(bin)
}
dockerPush() 🔗
DockerPush packages the Go binary into a container image and pushes it to a registry
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
bin | Directory ! | - | bin is the directory containing the cross-platform Go binaries |
image | String ! | - | image is the name of the image to push |
platforms | [String ! ] | ["linux/amd64", "linux/arm64"] | platforms is the list of platforms to build the container image for |
registryAddress | String | "docker.io" | registryAddress is the address of the container registry |
registryUser | String ! | - | registryUser is the username for the container registry |
registryPassword | Secret ! | - | registryPassword is the password for the container registry |
Example
dagger -m github.com/felipecruz91/daggerverse/go@6c9236806dde39ab788709b4ad6810a8f8a63b61 call \
docker-push --bin DIR_PATH --image string --registry-user string --registry-password env:MYSECRET
func (m *myModule) example(ctx context.Context, bin *Directory, image string, registryUser string, registryPassword *Secret) string {
return dag.
GoDagger().
DockerPush(ctx, bin, image, registryUser, registryPassword)
}
@function
async def example(bin: dagger.Directory, image: str, registry_user: str, registry_password: dagger.Secret) -> str:
return await (
dag.go_dagger()
.docker_push(bin, image, registry_user, registry_password)
)
@func()
async example(bin: Directory, image: string, registryUser: string, registryPassword: Secret): Promise<string> {
return dag
.goDagger()
.dockerPush(bin, image, registryUser, registryPassword)
}