go
No long description provided.
Installation
dagger install github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2Entrypoint
Return Type
Go !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Project source directory |
| version | String | "1.25.0" | Go version |
| moduleCache | CacheVolume | - | Use a custom module cache |
| buildCache | CacheVolume | - | Use a custom build cache |
| base | Container | - | Use a custom base container. The container must have Go installed. |
| ldflags | [String ! ] | - | Pass arguments to 'go build -ldflags'' |
| values | [String ! ] | - | Add string value definition of the form importpath.name=value Example: "github.com/my/module.Foo=bar" |
| cgo | Boolean | - | Enable CGO |
| race | Boolean | - | Enable race detector. Implies cgo=true |
| experiment | [String ! ] | - | Enable go experiments https://pkg.go.dev/internal/goexperiment |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Go {
return dag.
Go(source)
}@function
def example(source: dagger.Directory, ) -> dagger.Go:
return (
dag.go(source)
)@func()
example(source: Directory, ): Go {
return dag
.go(source)
}Types
Go 🔗
A Go project
version() 🔗
Go version
Return Type
String ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH versionfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
Go(source).
Version(ctx)
}@function
async def example(source: dagger.Directory, ) -> str:
return await (
dag.go(source)
.version()
)@func()
async example(source: Directory, ): Promise<string> {
return dag
.go(source)
.version()
}source() 🔗
Project source directory
Return Type
Directory ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH sourcefunc (m *MyModule) Example(source *dagger.Directory) *dagger.Directory {
return dag.
Go(source).
Source()
}@function
def example(source: dagger.Directory, ) -> dagger.Directory:
return (
dag.go(source)
.source()
)@func()
example(source: Directory, ): Directory {
return dag
.go(source)
.source()
}moduleCache() 🔗
Go module cache
Return Type
CacheVolume ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH module-cachefunc (m *MyModule) Example(source *dagger.Directory) *dagger.CacheVolume {
return dag.
Go(source).
ModuleCache()
}@function
def example(source: dagger.Directory, ) -> dagger.CacheVolume:
return (
dag.go(source)
.module_cache()
)@func()
example(source: Directory, ): CacheVolume {
return dag
.go(source)
.moduleCache()
}buildCache() 🔗
Go build cache
Return Type
CacheVolume ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH build-cachefunc (m *MyModule) Example(source *dagger.Directory) *dagger.CacheVolume {
return dag.
Go(source).
BuildCache()
}@function
def example(source: dagger.Directory, ) -> dagger.CacheVolume:
return (
dag.go(source)
.build_cache()
)@func()
example(source: Directory, ): CacheVolume {
return dag
.go(source)
.buildCache()
}base() 🔗
Base container from which to run all operations
Return Type
Container ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH basefunc (m *MyModule) Example(source *dagger.Directory) *dagger.Container {
return dag.
Go(source).
Base()
}@function
def example(source: dagger.Directory, ) -> dagger.Container:
return (
dag.go(source)
.base()
)@func()
example(source: Directory, ): Container {
return dag
.go(source)
.base()
}ldflags() 🔗
Pass arguments to ‘go build -ldflags”
Return Type
[String ! ] ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH ldflagsfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) []string {
return dag.
Go(source).
Ldflags(ctx)
}@function
async def example(source: dagger.Directory, ) -> List[str]:
return await (
dag.go(source)
.ldflags()
)@func()
async example(source: Directory, ): Promise<string[]> {
return dag
.go(source)
.ldflags()
}values() 🔗
Add string value definition of the form importpath.name=value
Return Type
[String ! ] ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH valuesfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) []string {
return dag.
Go(source).
Values(ctx)
}@function
async def example(source: dagger.Directory, ) -> List[str]:
return await (
dag.go(source)
.values()
)@func()
async example(source: Directory, ): Promise<string[]> {
return dag
.go(source)
.values()
}cgo() 🔗
Enable CGO
Return Type
Boolean ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH cgofunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) bool {
return dag.
Go(source).
Cgo(ctx)
}@function
async def example(source: dagger.Directory, ) -> bool:
return await (
dag.go(source)
.cgo()
)@func()
async example(source: Directory, ): Promise<boolean> {
return dag
.go(source)
.cgo()
}race() 🔗
Enable race detector
Return Type
Boolean ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH racefunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) bool {
return dag.
Go(source).
Race(ctx)
}@function
async def example(source: dagger.Directory, ) -> bool:
return await (
dag.go(source)
.race()
)@func()
async example(source: Directory, ): Promise<boolean> {
return dag
.go(source)
.race()
}experiment() 🔗
Enable go experiments
Return Type
[String ! ] ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH experimentfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) []string {
return dag.
Go(source).
Experiment(ctx)
}@function
async def example(source: dagger.Directory, ) -> List[str]:
return await (
dag.go(source)
.experiment()
)@func()
async example(source: Directory, ): Promise<string[]> {
return dag
.go(source)
.experiment()
}download() 🔗
Download dependencies into the module cache
Return Type
Go ! Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH downloadfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Go {
return dag.
Go(source).
Download()
}@function
def example(source: dagger.Directory, ) -> dagger.Go:
return (
dag.go(source)
.download()
)@func()
example(source: Directory, ): Go {
return dag
.go(source)
.download()
}env() 🔗
Prepare a build environment for the given Go source code: - Build a base container with Go tooling installed and configured - Apply configuration - Mount the source code
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| platform | Scalar | - | No description provided |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH envfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Container {
return dag.
Go(source).
Env()
}@function
def example(source: dagger.Directory, ) -> dagger.Container:
return (
dag.go(source)
.env()
)@func()
example(source: Directory, ): Container {
return dag
.go(source)
.env()
}tests() 🔗
List tests
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkgs | [String ! ] | ["./..."] | Packages to list tests from (default all packages) |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH testsfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
Go(source).
Tests(ctx)
}@function
async def example(source: dagger.Directory, ) -> str:
return await (
dag.go(source)
.tests()
)@func()
async example(source: Directory, ): Promise<string> {
return dag
.go(source)
.tests()
}build() 🔗
Build the given main packages, and return the build directory
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkgs | [String ! ] | ["./..."] | Which targets to build (default all main packages) |
| noSymbols | Boolean | - | Disable symbol table |
| noDwarf | Boolean | - | Disable DWARF generation |
| platform | Scalar | - | Target build platform |
| output | String | "./bin/" | Output directory |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH buildfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Directory {
return dag.
Go(source).
Build()
}@function
def example(source: dagger.Directory, ) -> dagger.Directory:
return (
dag.go(source)
.build()
)@func()
example(source: Directory, ): Directory {
return dag
.go(source)
.build()
}binary() 🔗
Build a single main package, and return the compiled binary
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkg | String ! | - | Which package to build |
| noSymbols | Boolean | - | Disable symbol table |
| noDwarf | Boolean | - | Disable DWARF generation |
| platform | Scalar | - | Target build platform |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH binary --pkg stringfunc (m *MyModule) Example(source *dagger.Directory, pkg string) *dagger.File {
return dag.
Go(source).
Binary(pkg)
}@function
def example(source: dagger.Directory, pkg: str) -> dagger.File:
return (
dag.go(source)
.binary(pkg)
)@func()
example(source: Directory, pkg: string): File {
return dag
.go(source)
.binary(pkg)
}test() 🔗
Run tests for the given packages
Return Type
Void !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| run | String | - | Only run these tests |
| skip | String | - | Skip these tests |
| failfast | Boolean | - | Abort test run on first failure |
| parallel | Integer | 0 | How many tests to run in parallel - defaults to the number of CPUs |
| timeout | String | "30m" | How long before timing out the test run |
| count | Integer | 1 | No description provided |
| pkgs | [String ! ] | ["./..."] | Which packages to test |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH testfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) {
return dag.
Go(source).
Test(ctx)
}@function
async def example(source: dagger.Directory, ) -> None:
return await (
dag.go(source)
.test()
)@func()
async example(source: Directory, ): Promise<void> {
return dag
.go(source)
.test()
}listPackages() 🔗
List packages matching the specified criteria
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkgs | [String ! ] | ["./..."] | Filter by name or pattern. Example './foo/...' |
| onlyMain | Boolean | - | Only list main packages |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH list-packagesfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) []string {
return dag.
Go(source).
ListPackages(ctx)
}@function
async def example(source: dagger.Directory, ) -> List[str]:
return await (
dag.go(source)
.list_packages()
)@func()
async example(source: Directory, ): Promise<string[]> {
return dag
.go(source)
.listPackages()
}lint() 🔗
Lint the project
Return Type
Void !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| packages | [String ! ] | - | No description provided |
Example
dagger -m github.com/reconsumeralization/dagger/modules/go@457a78abd2aa40f9c194f6f395c7d816e57db0c2 call \
--source DIR_PATH lintfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) {
return dag.
Go(source).
Lint(ctx)
}@function
async def example(source: dagger.Directory, ) -> None:
return await (
dag.go(source)
.lint()
)@func()
async example(source: Directory, ): Promise<void> {
return dag
.go(source)
.lint()
}