Dagger
Search

go

Go programming language module.

Installation

dagger install github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
versionString -Version (image tag) to use from the official image repository as a base container.
containerContainer -Custom container to use as a base container.
disableCacheBoolean -Disable mounting cache volumes.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
func (m *myModule) example() *Go  {
	return dag.
			Go()
}
@function
def example() -> dag.Go:
	return (
		dag.go()
	)
@func()
example(): Go {
	return dag
		.go()
}

Types

Go 🔗

container() 🔗

Return Type
Container !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 container
func (m *myModule) example() *Container  {
	return dag.
			Go().
			Container()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.container()
	)
@func()
example(): Container {
	return dag
		.go()
		.container()
}

withEnvVariable() 🔗

Set an environment variable.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
nameString !-The name of the environment variable (e.g., "HOST").
valueString !-The value of the environment variable (e.g., "localhost").
expandBoolean -Replace `${VAR}` or $VAR in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-env-variable --name string --value string
func (m *myModule) example(name string, value string) *Go  {
	return dag.
			Go().
			WithEnvVariable(name, value)
}
@function
def example(name: str, value: str) -> dag.Go:
	return (
		dag.go()
		.with_env_variable(name, value)
	)
@func()
example(name: string, value: string): Go {
	return dag
		.go()
		.withEnvVariable(name, value)
}

withServiceBinding() 🔗

Establish a runtime dependency on a service.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
aliasString !-A name that can be used to reach the service from the container.
serviceService !-Identifier of the service container.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-service-binding --alias string --service PROTOCOL://HOST:PORT
func (m *myModule) example(alias string, service *Service) *Go  {
	return dag.
			Go().
			WithServiceBinding(alias, service)
}
@function
def example(alias: str, service: dagger.Service) -> dag.Go:
	return (
		dag.go()
		.with_service_binding(alias, service)
	)
@func()
example(alias: string, service: Service): Go {
	return dag
		.go()
		.withServiceBinding(alias, service)
}

withPlatform() 🔗

Set GOOS, GOARCH and GOARM environment variables.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
platformScalar !-Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-platform
func (m *myModule) example(platform ) *Go  {
	return dag.
			Go().
			WithPlatform(platform)
}
@function
def example(platform: ) -> dag.Go:
	return (
		dag.go()
		.with_platform(platform)
	)
@func()
example(platform: ): Go {
	return dag
		.go()
		.withPlatform(platform)
}

withCgoEnabled() 🔗

Set CGO_ENABLED environment variable to 1.

Return Type
Go !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-cgo-enabled
func (m *myModule) example() *Go  {
	return dag.
			Go().
			WithCgoEnabled()
}
@function
def example() -> dag.Go:
	return (
		dag.go()
		.with_cgo_enabled()
	)
@func()
example(): Go {
	return dag
		.go()
		.withCgoEnabled()
}

withCgoDisabled() 🔗

Set CGO_ENABLED environment variable to 0.

Return Type
Go !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-cgo-disabled
func (m *myModule) example() *Go  {
	return dag.
			Go().
			WithCgoDisabled()
}
@function
def example() -> dag.Go:
	return (
		dag.go()
		.with_cgo_disabled()
	)
@func()
example(): Go {
	return dag
		.go()
		.withCgoDisabled()
}

withModuleCache() 🔗

Mount a cache volume for Go module cache.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
cacheCacheVolume !-No description provided
sourceDirectory -Identifier of the directory to use as the cache volume's root.
sharingEnum -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-module-cache --cache VOLUME_NAME
func (m *myModule) example(cache *CacheVolume) *Go  {
	return dag.
			Go().
			WithModuleCache(cache)
}
@function
def example(cache: dagger.CacheVolume) -> dag.Go:
	return (
		dag.go()
		.with_module_cache(cache)
	)
@func()
example(cache: CacheVolume): Go {
	return dag
		.go()
		.withModuleCache(cache)
}

withBuildCache() 🔗

Mount a cache volume for Go build cache.

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
cacheCacheVolume !-No description provided
sourceDirectory -Identifier of the directory to use as the cache volume's root.
sharingEnum -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-build-cache --cache VOLUME_NAME
func (m *myModule) example(cache *CacheVolume) *Go  {
	return dag.
			Go().
			WithBuildCache(cache)
}
@function
def example(cache: dagger.CacheVolume) -> dag.Go:
	return (
		dag.go()
		.with_build_cache(cache)
	)
@func()
example(cache: CacheVolume): Go {
	return dag
		.go()
		.withBuildCache(cache)
}

exec() 🔗

Run a Go command.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
args[String ! ] !-Arguments to pass to the Go command.
srcDirectory -Source directory to mount.
platformScalar -Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 exec --args string1 --args string2
func (m *myModule) example(args []string) *Container  {
	return dag.
			Go().
			Exec(args)
}
@function
def example(args: List[str]) -> dagger.Container:
	return (
		dag.go()
		.exec(args)
	)
@func()
example(args: string[]): Container {
	return dag
		.go()
		.exec(args)
}

generate() 🔗

Run “go generate” command.

Consult “go help generate” for more information.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Source directory to mount.
packages[String ! ] -Packages (or files) to run "go generate" on.
runString -A regular expression to select directives whose full original source text (excluding any trailing spaces and final newline) matches the expression.
skipString -A regular expression to suppress directives whose full original source text (excluding any trailing spaces and final newline) matches the expression.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 generate --source DIR_PATH
func (m *myModule) example(source *Directory) *Directory  {
	return dag.
			Go().
			Generate(source)
}
@function
def example(source: dagger.Directory) -> dagger.Directory:
	return (
		dag.go()
		.generate(source)
	)
@func()
example(source: Directory): Directory {
	return dag
		.go()
		.generate(source)
}

build() 🔗

Build a binary.

Return Type
File !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Source directory to mount.
pkgString -Package to compile.
raceBoolean -Enable data race detection.
ldflags[String ! ] -Arguments to pass on each go tool link invocation.
tags[String ! ] -A list of additional build tags to consider satisfied during the build.
trimpathBoolean -Remove all file system paths from the resulting executable.
rawArgs[String ! ] -Additional args to pass to the build command.
platformScalar -Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 build --source DIR_PATH
func (m *myModule) example(source *Directory) *File  {
	return dag.
			Go().
			Build(source)
}
@function
def example(source: dagger.Directory) -> dagger.File:
	return (
		dag.go()
		.build(source)
	)
@func()
example(source: Directory): File {
	return dag
		.go()
		.build(source)
}

withSource() 🔗

Mount a source directory.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Source directory to mount.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH
func (m *myModule) example(source *Directory) *GoWithSource  {
	return dag.
			Go().
			WithSource(source)
}
@function
def example(source: dagger.Directory) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
	)
@func()
example(source: Directory): GoWithSource {
	return dag
		.go()
		.withSource(source)
}

WithSource 🔗

source() 🔗

Return Type
Directory !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 source
func (m *myModule) example(source *Directory) *Directory  {
	return dag.
			Go().
			WithSource(source).
			Source()
}
@function
def example(source: dagger.Directory) -> dagger.Directory:
	return (
		dag.go()
		.with_source(source)
		.source()
	)
@func()
example(source: Directory): Directory {
	return dag
		.go()
		.withSource(source)
		.source()
}

container() 🔗

Return Type
Container !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 container
func (m *myModule) example(source *Directory) *Container  {
	return dag.
			Go().
			WithSource(source).
			Container()
}
@function
def example(source: dagger.Directory) -> dagger.Container:
	return (
		dag.go()
		.with_source(source)
		.container()
	)
@func()
example(source: Directory): Container {
	return dag
		.go()
		.withSource(source)
		.container()
}

withEnvVariable() 🔗

Set an environment variable.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
nameString !-The name of the environment variable (e.g., "HOST").
valueString !-The value of the environment variable (e.g., "localhost").
expandBoolean -Replace `${VAR}` or $VAR in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-env-variable --name string --value string
func (m *myModule) example(source *Directory, name string, value string) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithEnvVariable(name, value)
}
@function
def example(source: dagger.Directory, name: str, value: str) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_env_variable(name, value)
	)
@func()
example(source: Directory, name: string, value: string): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withEnvVariable(name, value)
}

withServiceBinding() 🔗

Establish a runtime dependency on a service.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
aliasString !-A name that can be used to reach the service from the container.
serviceService !-Identifier of the service container.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-service-binding --alias string --service PROTOCOL://HOST:PORT
func (m *myModule) example(source *Directory, alias string, service *Service) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithServiceBinding(alias, service)
}
@function
def example(source: dagger.Directory, alias: str, service: dagger.Service) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_service_binding(alias, service)
	)
@func()
example(source: Directory, alias: string, service: Service): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withServiceBinding(alias, service)
}

withPlatform() 🔗

Set GOOS, GOARCH and GOARM environment variables.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
platformScalar !-Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-platform
func (m *myModule) example(source *Directory, platform ) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithPlatform(platform)
}
@function
def example(source: dagger.Directory, platform: ) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_platform(platform)
	)
@func()
example(source: Directory, platform: ): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withPlatform(platform)
}

withCgoEnabled() 🔗

Set CGO_ENABLED environment variable to 1.

Return Type
WithSource !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-cgo-enabled
func (m *myModule) example(source *Directory) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithCgoEnabled()
}
@function
def example(source: dagger.Directory) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_cgo_enabled()
	)
@func()
example(source: Directory): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withCgoEnabled()
}

withCgoDisabled() 🔗

Set CGO_ENABLED environment variable to 0.

Return Type
WithSource !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-cgo-disabled
func (m *myModule) example(source *Directory) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithCgoDisabled()
}
@function
def example(source: dagger.Directory) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_cgo_disabled()
	)
@func()
example(source: Directory): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withCgoDisabled()
}

withModuleCache() 🔗

Mount a cache volume for Go module cache.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
cacheCacheVolume !-No description provided
sourceDirectory -Identifier of the directory to use as the cache volume's root.
sharingEnum -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-module-cache --cache VOLUME_NAME
func (m *myModule) example(source *Directory, cache *CacheVolume) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithModuleCache(cache)
}
@function
def example(source: dagger.Directory, cache: dagger.CacheVolume) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_module_cache(cache)
	)
@func()
example(source: Directory, cache: CacheVolume): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withModuleCache(cache)
}

withBuildCache() 🔗

Mount a cache volume for Go build cache.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
cacheCacheVolume !-No description provided
sourceDirectory -Identifier of the directory to use as the cache volume's root.
sharingEnum -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-build-cache --cache VOLUME_NAME
func (m *myModule) example(source *Directory, cache *CacheVolume) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithBuildCache(cache)
}
@function
def example(source: dagger.Directory, cache: dagger.CacheVolume) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_build_cache(cache)
	)
@func()
example(source: Directory, cache: CacheVolume): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withBuildCache(cache)
}

withExec() 🔗

Run a Go command.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
args[String ! ] !-Arguments to pass to the Go command.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 with-exec --args string1 --args string2
func (m *myModule) example(source *Directory, args []string) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			WithExec(args)
}
@function
def example(source: dagger.Directory, args: List[str]) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.with_exec(args)
	)
@func()
example(source: Directory, args: string[]): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.withExec(args)
}

exec() 🔗

Run a Go command.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
args[String ! ] !-Arguments to pass to the Go command.
platformScalar -Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 exec --args string1 --args string2
func (m *myModule) example(source *Directory, args []string) *Container  {
	return dag.
			Go().
			WithSource(source).
			Exec(args)
}
@function
def example(source: dagger.Directory, args: List[str]) -> dagger.Container:
	return (
		dag.go()
		.with_source(source)
		.exec(args)
	)
@func()
example(source: Directory, args: string[]): Container {
	return dag
		.go()
		.withSource(source)
		.exec(args)
}

generate() 🔗

Run “go generate” command.

Consult “go help generate” for more information.

Return Type
WithSource !
Arguments
NameTypeDefault ValueDescription
packages[String ! ] -Packages (or files) to run "go generate" on.
runString -A regular expression to select directives whose full original source text (excluding any trailing spaces and final newline) matches the expression.
skipString -A regular expression to suppress directives whose full original source text (excluding any trailing spaces and final newline) matches the expression.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 generate
func (m *myModule) example(source *Directory) *GoWithSource  {
	return dag.
			Go().
			WithSource(source).
			Generate()
}
@function
def example(source: dagger.Directory) -> dag.GoWithSource:
	return (
		dag.go()
		.with_source(source)
		.generate()
	)
@func()
example(source: Directory): GoWithSource {
	return dag
		.go()
		.withSource(source)
		.generate()
}

build() 🔗

Compile the packages into a binary.

Return Type
File !
Arguments
NameTypeDefault ValueDescription
pkgString -Package to compile.
raceBoolean -Enable data race detection.
ldflags[String ! ] -Arguments to pass on each go tool link invocation.
tags[String ! ] -A list of additional build tags to consider satisfied during the build.
trimpathBoolean -Remove all file system paths from the resulting executable.
rawArgs[String ! ] -Additional args to pass to the build command.
platformScalar -Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
dagger -m github.com/sagikazarmark/daggerverse/go@0c841651cbcf03766b41a8c172b681f99c64967b call \
 with-source --source DIR_PATH \
 build
func (m *myModule) example(source *Directory) *File  {
	return dag.
			Go().
			WithSource(source).
			Build()
}
@function
def example(source: dagger.Directory) -> dagger.File:
	return (
		dag.go()
		.with_source(source)
		.build()
	)
@func()
example(source: Directory): File {
	return dag
		.go()
		.withSource(source)
		.build()
}