go
Go programming language module.
Installation
dagger install github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680Entrypoint
Return Type
Go !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| version | String | - | Version (image tag) to use from the official image repository as a base container. |
| container | Container | - | Custom container to use as a base container. |
| disableCache | Boolean | - | Disable mounting cache volumes. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
func (m *MyModule) Example() *dagger.Go {
return dag.
Go()
}@function
def example() -> dagger.Go:
return (
dag.go()
)@func()
example(): Go {
return dag
.go()
}Types
Go 🔗
container() 🔗
Return Type
Container ! Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
containerfunc (m *MyModule) Example() *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| name | String ! | - | The name of the environment variable (e.g., "HOST"). |
| value | String ! | - | The value of the environment variable (e.g., "localhost"). |
| expand | Boolean | - | 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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-env-variable --name string --value stringfunc (m *MyModule) Example(name string, value string) *dagger.Go {
return dag.
Go().
WithEnvVariable(name, value)
}@function
def example(name: str, value: str) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| alias | String ! | - | A name that can be used to reach the service from the container. |
| service | Service ! | - | Identifier of the service container. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-service-binding --alias string --service PROTOCOL://HOST:PORTfunc (m *MyModule) Example(alias string, service *dagger.Service) *dagger.Go {
return dag.
Go().
WithServiceBinding(alias, service)
}@function
def example(alias: str, service: dagger.Service) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| platform | Scalar ! | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-platformfunc (m *MyModule) Example(platform ) *dagger.Go {
return dag.
Go().
WithPlatform(platform)
}@function
def example(platform: ) -> dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-cgo-enabledfunc (m *MyModule) Example() *dagger.Go {
return dag.
Go().
WithCgoEnabled()
}@function
def example() -> dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-cgo-disabledfunc (m *MyModule) Example() *dagger.Go {
return dag.
Go().
WithCgoDisabled()
}@function
def example() -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| cache | CacheVolume ! | - | No description provided |
| source | Directory | - | Identifier of the directory to use as the cache volume's root. |
| sharing | Enum | - | Sharing mode of the cache volume. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-module-cache --cache VOLUME_NAMEfunc (m *MyModule) Example(cache *dagger.CacheVolume) *dagger.Go {
return dag.
Go().
WithModuleCache(cache)
}@function
def example(cache: dagger.CacheVolume) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| cache | CacheVolume ! | - | No description provided |
| source | Directory | - | Identifier of the directory to use as the cache volume's root. |
| sharing | Enum | - | Sharing mode of the cache volume. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-build-cache --cache VOLUME_NAMEfunc (m *MyModule) Example(cache *dagger.CacheVolume) *dagger.Go {
return dag.
Go().
WithBuildCache(cache)
}@function
def example(cache: dagger.CacheVolume) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| args | [String ! ] ! | - | Arguments to pass to the Go command. |
| src | Directory | - | Source directory to mount. |
| platform | Scalar | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
exec --args string1 --args string2func (m *MyModule) Example(args []string) *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory to mount. |
| packages | [String ! ] | - | Packages (or files) to run "go generate" on. |
| run | String | - | A regular expression to select directives whose full original source text (excluding any trailing spaces and final newline) matches the expression. |
| skip | String | - | 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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
generate --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory to mount. |
| pkg | String | - | Package to compile. |
| race | Boolean | - | 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. |
| trimpath | Boolean | - | Remove all file system paths from the resulting executable. |
| rawArgs | [String ! ] | - | Additional args to pass to the build command. |
| platform | Scalar | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
build --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory to mount. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.GoWithSource {
return dag.
Go().
WithSource(source)
}@function
def example(source: dagger.Directory) -> dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
sourcefunc (m *MyModule) Example(source *dagger.Directory) *dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
containerfunc (m *MyModule) Example(source *dagger.Directory) *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| name | String ! | - | The name of the environment variable (e.g., "HOST"). |
| value | String ! | - | The value of the environment variable (e.g., "localhost"). |
| expand | Boolean | - | 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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-env-variable --name string --value stringfunc (m *MyModule) Example(source *dagger.Directory, name string, value string) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithEnvVariable(name, value)
}@function
def example(source: dagger.Directory, name: str, value: str) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| alias | String ! | - | A name that can be used to reach the service from the container. |
| service | Service ! | - | Identifier of the service container. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-service-binding --alias string --service PROTOCOL://HOST:PORTfunc (m *MyModule) Example(source *dagger.Directory, alias string, service *dagger.Service) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithServiceBinding(alias, service)
}@function
def example(source: dagger.Directory, alias: str, service: dagger.Service) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| platform | Scalar ! | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-platformfunc (m *MyModule) Example(source *dagger.Directory, platform ) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithPlatform(platform)
}@function
def example(source: dagger.Directory, platform: ) -> dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-cgo-enabledfunc (m *MyModule) Example(source *dagger.Directory) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithCgoEnabled()
}@function
def example(source: dagger.Directory) -> dagger.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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-cgo-disabledfunc (m *MyModule) Example(source *dagger.Directory) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithCgoDisabled()
}@function
def example(source: dagger.Directory) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| cache | CacheVolume ! | - | No description provided |
| source | Directory | - | Identifier of the directory to use as the cache volume's root. |
| sharing | Enum | - | Sharing mode of the cache volume. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-module-cache --cache VOLUME_NAMEfunc (m *MyModule) Example(source *dagger.Directory, cache *dagger.CacheVolume) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithModuleCache(cache)
}@function
def example(source: dagger.Directory, cache: dagger.CacheVolume) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| cache | CacheVolume ! | - | No description provided |
| source | Directory | - | Identifier of the directory to use as the cache volume's root. |
| sharing | Enum | - | Sharing mode of the cache volume. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-build-cache --cache VOLUME_NAMEfunc (m *MyModule) Example(source *dagger.Directory, cache *dagger.CacheVolume) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithBuildCache(cache)
}@function
def example(source: dagger.Directory, cache: dagger.CacheVolume) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| args | [String ! ] ! | - | Arguments to pass to the Go command. |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
with-exec --args string1 --args string2func (m *MyModule) Example(source *dagger.Directory, args []string) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
WithExec(args)
}@function
def example(source: dagger.Directory, args: List[str]) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| args | [String ! ] ! | - | Arguments to pass to the Go command. |
| platform | Scalar | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
exec --args string1 --args string2func (m *MyModule) Example(source *dagger.Directory, args []string) *dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| packages | [String ! ] | - | Packages (or files) to run "go generate" on. |
| run | String | - | A regular expression to select directives whose full original source text (excluding any trailing spaces and final newline) matches the expression. |
| skip | String | - | 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/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
generatefunc (m *MyModule) Example(source *dagger.Directory) *dagger.GoWithSource {
return dag.
Go().
WithSource(source).
Generate()
}@function
def example(source: dagger.Directory) -> dagger.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
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkg | String | - | Package to compile. |
| race | Boolean | - | 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. |
| trimpath | Boolean | - | Remove all file system paths from the resulting executable. |
| rawArgs | [String ! ] | - | Additional args to pass to the build command. |
| platform | Scalar | - | Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). |
Example
dagger -m github.com/luanmtruong/daggerverse/go@96c13b929c636316317f745ff36cda4e4c66f680 call \
with-source --source DIR_PATH \
buildfunc (m *MyModule) Example(source *dagger.Directory) *dagger.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()
}