Dagger
Search

go

No long description provided.

Installation

dagger install github.com/aluzzardi/dagger/modules/go@aec13cdf85e7cc7aa5a933e3c73a2604f6e73b01

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
func (m *myModule) example(source *Directory) *Go  {
	return dag.
			Go(source)
}

Types

Go πŸ”—

A Go project

version() πŸ”—

Go version

Return Type
String !
Example
func (m *myModule) example(ctx context.Context, source *Directory) string  {
	return dag.
			Go(source).
			Version(ctx)
}

source() πŸ”—

Project source directory

Return Type
Directory !
Example
func (m *myModule) example(source *Directory) *Directory  {
	return dag.
			Go(source).
			Source()
}

moduleCache() πŸ”—

Go module cache

Return Type
CacheVolume !
Example
func (m *myModule) example(source *Directory) *CacheVolume  {
	return dag.
			Go(source).
			ModuleCache()
}

buildCache() πŸ”—

Go build cache

Return Type
CacheVolume !
Example
func (m *myModule) example(source *Directory) *CacheVolume  {
	return dag.
			Go(source).
			BuildCache()
}

base() πŸ”—

Base container from which to run all operations

Return Type
Container !
Example
func (m *myModule) example(source *Directory) *Container  {
	return dag.
			Go(source).
			Base()
}

ldflags() πŸ”—

Pass arguments to β€˜go build -ldflags”

Return Type
[String ! ] !
Example
func (m *myModule) example(ctx context.Context, source *Directory) []string  {
	return dag.
			Go(source).
			Ldflags(ctx)
}

values() πŸ”—

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

Return Type
[String ! ] !
Example
func (m *myModule) example(ctx context.Context, source *Directory) []string  {
	return dag.
			Go(source).
			Values(ctx)
}

cgo() πŸ”—

Enable CGO

Return Type
Boolean !
Example
func (m *myModule) example(ctx context.Context, source *Directory) bool  {
	return dag.
			Go(source).
			Cgo(ctx)
}

race() πŸ”—

Enable race detector

Return Type
Boolean !
Example
func (m *myModule) example(ctx context.Context, source *Directory) bool  {
	return dag.
			Go(source).
			Race(ctx)
}

download() πŸ”—

Download dependencies into the module cache

Return Type
Go !
Example
func (m *myModule) 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
func (m *myModule) 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
func (m *myModule) example(ctx context.Context, source *Directory) string  {
	return dag.
			Go(source).
			Tests(ctx)
}

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
func (m *myModule) 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
func (m *myModule) 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
func (m *myModule) example(ctx context.Context, source *Directory)   {
	return dag.
			Go(source).
			Test(ctx)
}

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
func (m *myModule) example(ctx context.Context, source *Directory) []string  {
	return dag.
			Go(source).
			ListPackages(ctx)
}

lint() πŸ”—

Lint the project

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
packages[String ! ] -No description provided
Example
func (m *myModule) example(ctx context.Context, source *Directory)   {
	return dag.
			Go(source).
			Lint(ctx)
}