go
Go programming language module.
Installation
dagger install github.com/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04
Entrypoint
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | Source directory to mount. |
Example
dagger -m github.com/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
Name | Type | Default Value | Description |
---|---|---|---|
args | [String ! ] ! | - | Arguments to pass to the Go command. |
Example
dagger -m github.com/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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
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/sagikazarmark/daggerverse/go@fb248d287658681298c8997f36575d6768c92c04 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()
}