Dagger
Search

go

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/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
sourceDirectory -The source directory to use for Go commands. This should contain a go.mod file.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
func (m *MyModule) Example() *dagger.Go  {
	return dag.
			Go()
}
@function
def example() -> dagger.Go:
	return (
		dag.go()
	)
@func()
example(): Go {
	return dag
		.go()
}

Types

Go 🔗

source() 🔗

Return Type
Directory !
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 source
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Go().
			Source()
}
@function
def example() -> dagger.Directory:
	return (
		dag.go()
		.source()
	)
@func()
example(): Directory {
	return dag
		.go()
		.source()
}

base() 🔗

Base returns a container with the Go source code mounted at /src and the working directory set to /src.

Return Type
Container !
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 base
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			Base()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.base()
	)
@func()
example(): Container {
	return dag
		.go()
		.base()
}

build() 🔗

Build runs the go build command in the source directory.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
pathString "."The path to the Go package or file to build.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 build
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Go().
			Build()
}
@function
def example() -> dagger.Directory:
	return (
		dag.go()
		.build()
	)
@func()
example(): Directory {
	return dag
		.go()
		.build()
}

container() 🔗

Container builds the Go application and creates a container with the built binary.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
pathString "."The path to the Go package or file to build.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 container
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			Container()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.container()
	)
@func()
example(): Container {
	return dag
		.go()
		.container()
}

debugContainer() 🔗

DebugContainer builds the Go application and creates a container with the built binary, using a debug-friendly base image.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
pathString "."The path to the Go package or file to build.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 debug-container
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			DebugContainer()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.debug_container()
	)
@func()
example(): Container {
	return dag
		.go()
		.debugContainer()
}

download() 🔗

Download runs the go mod download command in the source directory to download Go module dependencies.

Return Type
Container !
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 download
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			Download()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.download()
	)
@func()
example(): Container {
	return dag
		.go()
		.download()
}

goVersion() 🔗

GoVersion returns the Go version specified in the go.mod file, or “unknown” if it cannot be determined.

Return Type
String !
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 go-version
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			GoVersion(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.go_version()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.goVersion()
}

lint() 🔗

Lint runs the golangci-lint run command in the source directory to lint the Go code. It uses the latest version of golangci-lint.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
args[String ! ] []Lint args to pass to the golangci-lint command (e.g., "--fast", "--enable=golint"). These are optional and default to an empty list.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 lint
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			Lint(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.lint()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.lint()
}

publish() 🔗

Publish builds the Go application and pushes it to a container registry with the specified image name and registry credentials.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pathString "."The path to the Go package or file to build.
imageNameString "test:latest"imageName is the name of the container image to publish, including the tag (e.g., "my-nginx:latest").
registryString "docker.io"Registry is the registry to which the container should be pushed, defaulting to docker.io
usernameString -Username for the container registry, if authentication is required.
passwordSecret -Password for the container registry, if authentication is required.
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 publish
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			Publish(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.publish()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.publish()
}

test() 🔗

Test runs the go test command in the source directory.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
args[String ! ] []Test args
Example
dagger -m github.com/kdihalas/dagger/go@f5c477671acb90995479a89595b7f7e576b849d9 call \
 test
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			Test(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.test()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.test()
}