go
No long description provided.
Installation
dagger install github.com/aluzzardi/dagger/modules/go@aec13cdf85e7cc7aa5a933e3c73a2604f6e73b01
Entrypoint
Return Type
Go !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | Project source directory |
version | String | "1.23.2" | 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 |
Example
func (m *myModule) example(source *Directory) *Go {
return dag.
Go(source)
}
Types
Go π
A Go project
version() π
Go version
Return Type
String !
Example
func (m *myModule) example(ctx context.Context, source *Directory) string {
return dag.
Go(source).
Version(ctx)
}
source() π
Project source directory
Return Type
Directory !
Example
func (m *myModule) example(source *Directory) *Directory {
return dag.
Go(source).
Source()
}
moduleCache() π
Go module cache
Return Type
CacheVolume !
Example
func (m *myModule) example(source *Directory) *CacheVolume {
return dag.
Go(source).
ModuleCache()
}
buildCache() π
Go build cache
Return Type
CacheVolume !
Example
func (m *myModule) example(source *Directory) *CacheVolume {
return dag.
Go(source).
BuildCache()
}
base() π
Base container from which to run all operations
Return Type
Container !
Example
func (m *myModule) example(source *Directory) *Container {
return dag.
Go(source).
Base()
}
ldflags() π
Pass arguments to βgo build -ldflagsβ
Return Type
[String ! ] !
Example
func (m *myModule) example(ctx context.Context, source *Directory) []string {
return dag.
Go(source).
Ldflags(ctx)
}
values() π
Add string value definition of the form importpath.name=value
Return Type
[String ! ] !
Example
func (m *myModule) example(ctx context.Context, source *Directory) []string {
return dag.
Go(source).
Values(ctx)
}
cgo() π
Enable CGO
Return Type
Boolean !
Example
func (m *myModule) example(ctx context.Context, source *Directory) bool {
return dag.
Go(source).
Cgo(ctx)
}
race() π
Enable race detector
Return Type
Boolean !
Example
func (m *myModule) example(ctx context.Context, source *Directory) bool {
return dag.
Go(source).
Race(ctx)
}
download() π
Download dependencies into the module cache
Return Type
Go !
Example
func (m *myModule) 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
func (m *myModule) 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
func (m *myModule) example(ctx context.Context, source *Directory) string {
return dag.
Go(source).
Tests(ctx)
}
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
func (m *myModule) 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
func (m *myModule) 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
func (m *myModule) example(ctx context.Context, source *Directory) {
return dag.
Go(source).
Test(ctx)
}
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
func (m *myModule) example(ctx context.Context, source *Directory) []string {
return dag.
Go(source).
ListPackages(ctx)
}
lint() π
Lint the project
Return Type
Void !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
packages | [String ! ] | - | No description provided |
Example
func (m *myModule) example(ctx context.Context, source *Directory) {
return dag.
Go(source).
Lint(ctx)
}