Dagger
Search

go

No long description provided.

Installation

dagger install github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Project source directory
versionString "1.23.2"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
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH
func (m *myModule) example(source *Directory) *Go  {
	return dag.
			Go(source)
}
@function
def example(source: dagger.Directory, ) -> dag.Go:
	return (
		dag.go(source)
	)
@func()
example(source: Directory, ): Go {
	return dag
		.go(source)
}

Types

Go 🔗

A Go project

version() 🔗

Go version

Return Type
String !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH version
func (m *myModule) example(ctx context.Context, source *Directory) string  {
	return dag.
			Go(source).
			Version(ctx)
}
@function
async def example(source: dagger.Directory, ) -> str:
	return await (
		dag.go(source)
		.version()
	)
@func()
async example(source: Directory, ): Promise<string> {
	return dag
		.go(source)
		.version()
}

source() 🔗

Project source directory

Return Type
Directory !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH source
func (m *myModule) example(source *Directory) *Directory  {
	return dag.
			Go(source).
			Source()
}
@function
def example(source: dagger.Directory, ) -> dagger.Directory:
	return (
		dag.go(source)
		.source()
	)
@func()
example(source: Directory, ): Directory {
	return dag
		.go(source)
		.source()
}

moduleCache() 🔗

Go module cache

Return Type
CacheVolume !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH module-cache
func (m *myModule) example(source *Directory) *CacheVolume  {
	return dag.
			Go(source).
			ModuleCache()
}
@function
def example(source: dagger.Directory, ) -> dagger.CacheVolume:
	return (
		dag.go(source)
		.module_cache()
	)
@func()
example(source: Directory, ): CacheVolume {
	return dag
		.go(source)
		.moduleCache()
}

buildCache() 🔗

Go build cache

Return Type
CacheVolume !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH build-cache
func (m *myModule) example(source *Directory) *CacheVolume  {
	return dag.
			Go(source).
			BuildCache()
}
@function
def example(source: dagger.Directory, ) -> dagger.CacheVolume:
	return (
		dag.go(source)
		.build_cache()
	)
@func()
example(source: Directory, ): CacheVolume {
	return dag
		.go(source)
		.buildCache()
}

base() 🔗

Base container from which to run all operations

Return Type
Container !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH base
func (m *myModule) example(source *Directory) *Container  {
	return dag.
			Go(source).
			Base()
}
@function
def example(source: dagger.Directory, ) -> dagger.Container:
	return (
		dag.go(source)
		.base()
	)
@func()
example(source: Directory, ): Container {
	return dag
		.go(source)
		.base()
}

ldflags() 🔗

Pass arguments to ‘go build -ldflags”

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

values() 🔗

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

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

cgo() 🔗

Enable CGO

Return Type
Boolean !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH cgo
func (m *myModule) example(ctx context.Context, source *Directory) bool  {
	return dag.
			Go(source).
			Cgo(ctx)
}
@function
async def example(source: dagger.Directory, ) -> bool:
	return await (
		dag.go(source)
		.cgo()
	)
@func()
async example(source: Directory, ): Promise<boolean> {
	return dag
		.go(source)
		.cgo()
}

race() 🔗

Enable race detector

Return Type
Boolean !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH race
func (m *myModule) example(ctx context.Context, source *Directory) bool  {
	return dag.
			Go(source).
			Race(ctx)
}
@function
async def example(source: dagger.Directory, ) -> bool:
	return await (
		dag.go(source)
		.race()
	)
@func()
async example(source: Directory, ): Promise<boolean> {
	return dag
		.go(source)
		.race()
}

download() 🔗

Download dependencies into the module cache

Return Type
Go !
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH download
func (m *myModule) example(source *Directory) *Go  {
	return dag.
			Go(source).
			Download()
}
@function
def example(source: dagger.Directory, ) -> dag.Go:
	return (
		dag.go(source)
		.download()
	)
@func()
example(source: Directory, ): Go {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH env
func (m *myModule) example(source *Directory) *Container  {
	return dag.
			Go(source).
			Env()
}
@function
def example(source: dagger.Directory, ) -> dagger.Container:
	return (
		dag.go(source)
		.env()
	)
@func()
example(source: Directory, ): Container {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH tests
func (m *myModule) example(ctx context.Context, source *Directory) string  {
	return dag.
			Go(source).
			Tests(ctx)
}
@function
async def example(source: dagger.Directory, ) -> str:
	return await (
		dag.go(source)
		.tests()
	)
@func()
async example(source: Directory, ): Promise<string> {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH build
func (m *myModule) example(source *Directory) *Directory  {
	return dag.
			Go(source).
			Build()
}
@function
def example(source: dagger.Directory, ) -> dagger.Directory:
	return (
		dag.go(source)
		.build()
	)
@func()
example(source: Directory, ): Directory {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH binary --pkg string
func (m *myModule) example(source *Directory, pkg string) *File  {
	return dag.
			Go(source).
			Binary(pkg)
}
@function
def example(source: dagger.Directory, pkg: str) -> dagger.File:
	return (
		dag.go(source)
		.binary(pkg)
	)
@func()
example(source: Directory, pkg: string): File {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH test
func (m *myModule) example(ctx context.Context, source *Directory)   {
	return dag.
			Go(source).
			Test(ctx)
}
@function
async def example(source: dagger.Directory, ) -> None:
	return await (
		dag.go(source)
		.test()
	)
@func()
async example(source: Directory, ): Promise<void> {
	return dag
		.go(source)
		.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/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH list-packages
func (m *myModule) example(ctx context.Context, source *Directory) []string  {
	return dag.
			Go(source).
			ListPackages(ctx)
}
@function
async def example(source: dagger.Directory, ) -> List[str]:
	return await (
		dag.go(source)
		.list_packages()
	)
@func()
async example(source: Directory, ): Promise<string[]> {
	return dag
		.go(source)
		.listPackages()
}

lint() 🔗

Lint the project

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
packages[String ! ] -No description provided
Example
dagger -m github.com/shykes/dagger/modules/go@c3d2e98fe40ecc24e52d5a268e383b61b9a1932c call \
 --source DIR_PATH lint
func (m *myModule) example(ctx context.Context, source *Directory)   {
	return dag.
			Go(source).
			Lint(ctx)
}
@function
async def example(source: dagger.Directory, ) -> None:
	return await (
		dag.go(source)
		.lint()
	)
@func()
async example(source: Directory, ): Promise<void> {
	return dag
		.go(source)
		.lint()
}