Dagger
Search

go-dagger

This module has been generated via dagger init and serves as a reference to
basic 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
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
NameTypeDefault ValueDescription
sourceDirectory !-source is the directory containing the Go source code
goVersionString "1.22.0"goVersion is the version of Go to use for building the binary
ignoreCacheBoolean falseignoreCache is a flag to ignore the cache
raceBoolean falserace is a flag to include Go's built-in data race detector
verboseBoolean falseverbose is a flag to enable verbose output
Example
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
NameTypeDefault ValueDescription
sourceDirectory !-source is the directory containing the Go source code
golangCilintImageString "golangci/golangci-lint:v1.57.2"golangCILintImage is the container image to use for the linter
timeoutString "5m"timeout is the maximum time to run the linter
verboseBoolean falseverbose is a flag to enable verbose output
Example
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
NameTypeDefault ValueDescription
sourceDirectory !-source is the directory containing the Go source code
goVersionString "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
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
NameTypeDefault ValueDescription
binDirectory !-bin is the directory containing the cross-platform Go binaries
platformString -platform is the platform to build the binary for
Example
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
NameTypeDefault ValueDescription
binDirectory !-bin is the directory containing the cross-platform Go binaries
imageString !-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
registryAddressString "docker.io"registryAddress is the address of the container registry
registryUserString !-registryUser is the username for the container registry
registryPasswordSecret !-registryPassword is the password for the container registry
Example
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)
}