Dagger
Search

go

No long description provided.

Installation

dagger install github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
sourceDirectory -Project source directory
versionString "1.24.3"Go version
moduleCacheCacheVolume -Use a custom module cache
buildCacheCacheVolume -Use a custom build cache
baseContainer -Use a custom base container. The container must have Go installed.
ldflags[String ! ] -Pass arguments to 'go build -ldflags''
values[String ! ] -Add string value definition of the form importpath.name=value Example: "github.com/my/module.Foo=bar"
cgoBoolean -Enable CGO
raceBoolean -Enable race detector. Implies cgo=true
experiment[String ! ] -Enable go experiments https://pkg.go.dev/internal/goexperiment
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b 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 🔗

A Go project

version() 🔗

Go version

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

source() 🔗

Project source directory

Return Type
Directory !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b 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()
}

moduleCache() 🔗

Go module cache

Return Type
CacheVolume !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 module-cache
func (m *MyModule) Example() *dagger.CacheVolume  {
	return dag.
			Go().
			ModuleCache()
}
@function
def example() -> dagger.CacheVolume:
	return (
		dag.go()
		.module_cache()
	)
@func()
example(): CacheVolume {
	return dag
		.go()
		.moduleCache()
}

buildCache() 🔗

Go build cache

Return Type
CacheVolume !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 build-cache
func (m *MyModule) Example() *dagger.CacheVolume  {
	return dag.
			Go().
			BuildCache()
}
@function
def example() -> dagger.CacheVolume:
	return (
		dag.go()
		.build_cache()
	)
@func()
example(): CacheVolume {
	return dag
		.go()
		.buildCache()
}

base() 🔗

Base container from which to run all operations

Return Type
Container !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b 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()
}

ldflags() 🔗

Pass arguments to ‘go build -ldflags”

Return Type
[String ! ] !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 ldflags
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			Ldflags(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.ldflags()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.ldflags()
}

values() 🔗

Add string value definition of the form importpath.name=value

Return Type
[String ! ] !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 values
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			Values(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.values()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.values()
}

cgo() 🔗

Enable CGO

Return Type
Boolean !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 cgo
func (m *MyModule) Example(ctx context.Context) bool  {
	return dag.
			Go().
			Cgo(ctx)
}
@function
async def example() -> bool:
	return await (
		dag.go()
		.cgo()
	)
@func()
async example(): Promise<boolean> {
	return dag
		.go()
		.cgo()
}

race() 🔗

Enable race detector

Return Type
Boolean !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 race
func (m *MyModule) Example(ctx context.Context) bool  {
	return dag.
			Go().
			Race(ctx)
}
@function
async def example() -> bool:
	return await (
		dag.go()
		.race()
	)
@func()
async example(): Promise<boolean> {
	return dag
		.go()
		.race()
}

experiment() 🔗

Enable go experiments

Return Type
[String ! ] !
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 experiment
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			Experiment(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.experiment()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.experiment()
}

download() 🔗

Download dependencies into the module cache

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

env() 🔗

Prepare a build environment for the given Go source code: - Build a base container with Go tooling installed and configured - Apply configuration - Mount the source code

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
platformScalar -No description provided
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 env
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			Env()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.env()
	)
@func()
example(): Container {
	return dag
		.go()
		.env()
}

tests() 🔗

List tests

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pkgs[String ! ] ["./..."]Packages to list tests from (default all packages)
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 tests
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			Tests(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.tests()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.tests()
}

build() 🔗

Build the given main packages, and return the build directory

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
pkgs[String ! ] ["./..."]Which targets to build (default all main packages)
noSymbolsBoolean -Disable symbol table
noDwarfBoolean -Disable DWARF generation
platformScalar -Target build platform
outputString "./bin/"Output directory
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b 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()
}

binary() 🔗

Build a single main package, and return the compiled binary

Return Type
File !
Arguments
NameTypeDefault ValueDescription
pkgString !-Which package to build
noSymbolsBoolean -Disable symbol table
noDwarfBoolean -Disable DWARF generation
platformScalar -Target build platform
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 binary --pkg string
func (m *MyModule) Example(pkg string) *dagger.File  {
	return dag.
			Go().
			Binary(pkg)
}
@function
def example(pkg: str) -> dagger.File:
	return (
		dag.go()
		.binary(pkg)
	)
@func()
example(pkg: string): File {
	return dag
		.go()
		.binary(pkg)
}

test() 🔗

Run tests for the given packages

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
runString -Only run these tests
skipString -Skip these tests
failfastBoolean -Abort test run on first failure
parallelInteger 0How many tests to run in parallel - defaults to the number of CPUs
timeoutString "30m"How long before timing out the test run
countInteger 1No description provided
pkgs[String ! ] ["./..."]Which packages to test
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 test
func (m *MyModule) Example(ctx context.Context)   {
	return dag.
			Go().
			Test(ctx)
}
@function
async def example() -> None:
	return await (
		dag.go()
		.test()
	)
@func()
async example(): Promise<void> {
	return dag
		.go()
		.test()
}

listPackages() 🔗

List packages matching the specified criteria

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
pkgs[String ! ] ["./..."]Filter by name or pattern. Example './foo/...'
onlyMainBoolean -Only list main packages
Example
dagger -m github.com/shykes/x/go@871e549ef3cd4596916d6a0720bea37bc3e0728b call \
 list-packages
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			ListPackages(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.list_packages()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.listPackages()
}