go
High-level interfaces for building and testing Go code.
Installation
dagger install github.com/vito/daggerverse/go@v0.0.1
Entrypoint
Return Type
Go !
Arguments
Name | Type | Description |
---|---|---|
base | Container | No description provided |
modCache | CacheVolume | No description provided |
buildCache | CacheVolume | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 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 🔗
base() 🔗
Return Type
Container !
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
base
func (m *myModule) example() *Container {
return dag.
Go().
Base()
}
@function
def example() -> dagger.Container:
return (
dag.go()
.base()
)
@func()
example(): Container {
return dag
.go()
.base()
}
modCache() 🔗
Return Type
CacheVolume !
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
mod-cache
func (m *myModule) example() *CacheVolume {
return dag.
Go().
ModCache()
}
@function
def example() -> dagger.CacheVolume:
return (
dag.go()
.mod_cache()
)
@func()
example(): CacheVolume {
return dag
.go()
.modCache()
}
buildCache() 🔗
Return Type
CacheVolume !
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
build-cache
func (m *myModule) example() *CacheVolume {
return dag.
Go().
BuildCache()
}
@function
def example() -> dagger.CacheVolume:
return (
dag.go()
.build_cache()
)
@func()
example(): CacheVolume {
return dag
.go()
.buildCache()
}
fromVersion() 🔗
FromVersion sets the base image to the given Go version.
Return Type
Go !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String ! | - | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
from-version --version string
func (m *myModule) example(version string) *Go {
return dag.
Go().
FromVersion(version)
}
@function
def example(version: str) -> dag.Go:
return (
dag.go()
.from_version(version)
)
@func()
example(version: string): Go {
return dag
.go()
.fromVersion(version)
}
build() 🔗
Build builds Go code using the go build CLI.
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The directory containing code to build. |
packages | [String ! ] | - | Packages to build. |
subdir | String | - | Subdirectory in which to place the built artifacts. |
xDefs | [String ! ] | - | -X definitions to pass to go build -ldflags. |
static | Boolean | - | Whether to enable CGO. |
race | Boolean | - | Whether to build with race detection. |
goos | String | - | GOOS to pass to go build for cross-compilation. |
goarch | String | - | GOARCH to pass to go build. for cross-compilation |
buildFlags | [String ! ] | - | Arbitrary flags to pass along to go build. |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
build --src DIR_PATH
func (m *myModule) example(src *Directory) *Directory {
return dag.
Go().
Build(src)
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.go()
.build(src)
)
@func()
example(src: Directory): Directory {
return dag
.go()
.build(src)
}
test() 🔗
Test runs tests using the go test CLI.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The directory containing code to test. |
subdir | String | - | Subdirectory in which to run the tests, i.e. go run -C. This is useful when running tests in a Go module that refers to a parent module. |
packages | [String ! ] | - | Packages to test. |
verbose | Boolean | - | Run with -v. |
race | Boolean | - | Whether to run tests with race detection. |
testFlags | [String ! ] | - | Arbitrary flags to pass along to go test. |
insecureRootCapabilities | Boolean | - | Whether to run tests insecurely, i.e. with special privileges. |
nest | Boolean | - | Enable experimental Dagger nesting. |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
test --src DIR_PATH
func (m *myModule) example(src *Directory) *Container {
return dag.
Go().
Test(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
return (
dag.go()
.test(src)
)
@func()
example(src: Directory): Container {
return dag
.go()
.test(src)
}
gotestsum() 🔗
Gotestsum runs tests using the gotestsum CLI.
The base container must have the gotestsum CLI installed.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The directory containing code to test. |
packages | [String ! ] | - | Packages to test. |
format | String | "testname" | Gotestsum format to display. |
race | Boolean | - | Whether to run tests with race detection. |
insecureRootCapabilities | Boolean | - | Whether to run tests insecurely, i.e. with special privileges. |
nest | Boolean | - | Enable experimental Dagger nesting. |
goTestFlags | [String ! ] | - | Arbitrary flags to pass along to go test. |
gotestsumFlags | [String ! ] | - | Arbitrary flags to pass along to gotestsum. |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
gotestsum --src DIR_PATH
func (m *myModule) example(src *Directory) *Container {
return dag.
Go().
Gotestsum(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
return (
dag.go()
.gotestsum(src)
)
@func()
example(src: Directory): Container {
return dag
.go()
.gotestsum(src)
}
generate() 🔗
Generate runs go generate ./… and returns the updated directory.
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
generate --src DIR_PATH
func (m *myModule) example(src *Directory) *Directory {
return dag.
Go().
Generate(src)
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.go()
.generate(src)
)
@func()
example(src: Directory): Directory {
return dag
.go()
.generate(src)
}
golangCilint() 🔗
GolangCILint runs golangci-lint.
The base container must have the golangci-lint CLI installed.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
verbose | Boolean | - | No description provided |
timeoutInSeconds | Integer | - | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
golang-cilint --src DIR_PATH
func (m *myModule) example(src *Directory) *Container {
return dag.
Go().
GolangCilint(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
return (
dag.go()
.golang_cilint(src)
)
@func()
example(src: Directory): Container {
return dag
.go()
.golangCilint(src)
}
globalCache() 🔗
GlobalCache sets \(GOMODCACHE to /go/pkg/mod and \)GOCACHE to /go/build-cache and mounts cache volumes to both.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
ctr | Container ! | - | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
global-cache --ctr IMAGE:TAG
func (m *myModule) example(ctr *Container) *Container {
return dag.
Go().
GlobalCache(ctr)
}
@function
def example(ctr: dagger.Container) -> dagger.Container:
return (
dag.go()
.global_cache(ctr)
)
@func()
example(ctr: Container): Container {
return dag
.go()
.globalCache(ctr)
}
binPath() 🔗
BinPath sets \(GOBIN to /go/bin and prepends it to \)PATH.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
ctr | Container ! | - | No description provided |
Example
dagger -m github.com/vito/daggerverse/go@f7223d2d82fb91622cbb7954177388d995a98d59 call \
bin-path --ctr IMAGE:TAG
func (m *myModule) example(ctr *Container) *Container {
return dag.
Go().
BinPath(ctr)
}
@function
def example(ctr: dagger.Container) -> dagger.Container:
return (
dag.go()
.bin_path(ctr)
)
@func()
example(ctr: Container): Container {
return dag
.go()
.binPath(ctr)
}