Dagger
Search

go

High-level interfaces for building and testing Go code.

Installation

dagger install github.com/vito/daggerverse/go@v0.0.1

Entrypoint

Return Type
Go !
Arguments
NameTypeDescription
baseContainer No description provided
modCacheCacheVolume No description provided
buildCacheCacheVolume No description provided
Example
func (m *myModule) example() *Go  {
	return dag.
			Go()
}
@function
def example() -> dag.Go:
	return (
		dag.go()
	)
@func()
example(): Go {
	return dag
		.go()
}

Types

Go 🔗

base() 🔗

Return Type
Container !
Example
func (m *myModule) example() *Container  {
	return dag.
			Go().
			Base()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.base()
	)
@func()
example(): Container {
	return dag
		.go()
		.base()
}

modCache() 🔗

Return Type
CacheVolume !
Example
func (m *myModule) example() *CacheVolume  {
	return dag.
			Go().
			ModCache()
}
@function
def example() -> dagger.CacheVolume:
	return (
		dag.go()
		.mod_cache()
	)
@func()
example(): CacheVolume {
	return dag
		.go()
		.modCache()
}

buildCache() 🔗

Return Type
CacheVolume !
Example
func (m *myModule) example() *CacheVolume  {
	return dag.
			Go().
			BuildCache()
}
@function
def example() -> dagger.CacheVolume:
	return (
		dag.go()
		.build_cache()
	)
@func()
example(): CacheVolume {
	return dag
		.go()
		.buildCache()
}

globalCache() 🔗

GlobalCache sets \(GOMODCACHE to /go/pkg/mod and \)GOCACHE to /go/build-cache and mounts cache volumes to both.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
ctrContainer !-No description provided
Example
func (m *myModule) example(ctr *Container) *Container  {
	return dag.
			Go().
			GlobalCache(ctr)
}
@function
def example(ctr: dagger.Container) -> dagger.Container:
	return (
		dag.go()
		.global_cache(ctr)
	)
@func()
example(ctr: Container): Container {
	return dag
		.go()
		.globalCache(ctr)
}

binPath() 🔗

BinPath sets \(GOBIN to /go/bin and prepends it to \)PATH.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
ctrContainer !-No description provided
Example
func (m *myModule) example(ctr *Container) *Container  {
	return dag.
			Go().
			BinPath(ctr)
}
@function
def example(ctr: dagger.Container) -> dagger.Container:
	return (
		dag.go()
		.bin_path(ctr)
	)
@func()
example(ctr: Container): Container {
	return dag
		.go()
		.binPath(ctr)
}

fromVersion() 🔗

FromVersion sets the base image to the given Go version.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
versionString !-No description provided
Example
func (m *myModule) example(version string) *Go  {
	return dag.
			Go().
			FromVersion(version)
}
@function
def example(version: str) -> dag.Go:
	return (
		dag.go()
		.from_version(version)
	)
@func()
example(version: string): Go {
	return dag
		.go()
		.fromVersion(version)
}

build() 🔗

Build builds Go code using the go build CLI.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to build.
packages[String ! ] -Packages to build.
subdirString -Subdirectory in which to place the built artifacts.
xDefs[String ! ] --X definitions to pass to go build -ldflags.
staticBoolean -Whether to enable CGO.
raceBoolean -Whether to build with race detection.
goosString -GOOS to pass to go build for cross-compilation.
goarchString -GOARCH to pass to go build. for cross-compilation
buildFlags[String ! ] -Arbitrary flags to pass along to go build.
Example
func (m *myModule) example(src *Directory) *Directory  {
	return dag.
			Go().
			Build(src)
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
	return (
		dag.go()
		.build(src)
	)
@func()
example(src: Directory): Directory {
	return dag
		.go()
		.build(src)
}

test() 🔗

Test runs tests using the go test CLI.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
subdirString -Subdirectory in which to run the tests, i.e. go run -C. This is useful when running tests in a Go module that refers to a parent module.
packages[String ! ] -Packages to test.
verboseBoolean -Run with -v.
raceBoolean -Whether to run tests with race detection.
testFlags[String ! ] -Arbitrary flags to pass along to go test.
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
nestBoolean -Enable experimental Dagger nesting.
Example
func (m *myModule) example(src *Directory) *Container  {
	return dag.
			Go().
			Test(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.go()
		.test(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.go()
		.test(src)
}

gotestsum() 🔗

Gotestsum runs tests using the gotestsum CLI.

The base container must have the gotestsum CLI installed.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
packages[String ! ] -Packages to test.
formatString "testname"Gotestsum format to display.
raceBoolean -Whether to run tests with race detection.
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
nestBoolean -Enable experimental Dagger nesting.
goTestFlags[String ! ] -Arbitrary flags to pass along to go test.
gotestsumFlags[String ! ] -Arbitrary flags to pass along to gotestsum.
Example
func (m *myModule) example(src *Directory) *Container  {
	return dag.
			Go().
			Gotestsum(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.go()
		.gotestsum(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.go()
		.gotestsum(src)
}

generate() 🔗

Generate runs go generate ./… and returns the updated directory.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-No description provided
Example
func (m *myModule) example(src *Directory) *Directory  {
	return dag.
			Go().
			Generate(src)
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
	return (
		dag.go()
		.generate(src)
	)
@func()
example(src: Directory): Directory {
	return dag
		.go()
		.generate(src)
}

golangCilint() 🔗

GolangCILint runs golangci-lint.

The base container must have the golangci-lint CLI installed.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-No description provided
verboseBoolean -No description provided
timeoutInSecondsInteger -No description provided
Example
func (m *myModule) example(src *Directory) *Container  {
	return dag.
			Go().
			GolangCilint(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.go()
		.golang_cilint(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.go()
		.golangCilint(src)
}