Dagger
Search

go

Go programming language module.

Installation

dagger install github.com/sagikazarmark/daggerverse/go@v0.3.0

Entrypoint

Return Type
Go !
Arguments
NameTypeDescription
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
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@4341f097b207ddcb180817a6a3fe974947a47490 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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-env-variable --name string --value string \
 exec --args string1 --args string2
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)
}

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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-platform \
 exec --args string1 --args string2
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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-cgo-enabled \
 exec --args string1 --args string2
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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-cgo-disabled \
 exec --args string1 --args string2
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.
sharingScalar -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-module-cache --cache VOLUME_NAME \
 exec --args string1 --args string2
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.
sharingScalar -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-build-cache --cache VOLUME_NAME \
 exec --args string1 --args string2
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@4341f097b207ddcb180817a6a3fe974947a47490 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)
}

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@4341f097b207ddcb180817a6a3fe974947a47490 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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 container
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 🔗

container() 🔗

Return Type
Container !
Example
dagger -m github.com/sagikazarmark/daggerverse/go@4341f097b207ddcb180817a6a3fe974947a47490 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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-env-variable --name string --value string \
 container
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)
}

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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-platform \
 container
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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-cgo-enabled \
 container
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@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-cgo-disabled \
 container
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.
sharingScalar -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-module-cache --cache VOLUME_NAME \
 container
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.
sharingScalar -Sharing mode of the cache volume.
Example
dagger -m github.com/sagikazarmark/daggerverse/go@4341f097b207ddcb180817a6a3fe974947a47490 call \
 with-source --source DIR_PATH \
 with-build-cache --cache VOLUME_NAME \
 container
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)
}

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@4341f097b207ddcb180817a6a3fe974947a47490 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)
}

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@4341f097b207ddcb180817a6a3fe974947a47490 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()
}