Dagger
Search

go

No long description provided.

Installation

dagger install github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c

Entrypoint

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
pathString !-Workspace-relative path of this directory.
wsWorkspace -Workspace containing this directory.
modulePathString !-Workspace-relative path of this directory's Go module root.
includeExtraFiles[String ! ] !-Extra workspace-root include patterns mounted for this directory's Go tests.
baseImageContainer !-Base image used by this directory's Go containers.
skipTestPaths[String ! ] !-Workspace-relative module roots or ancestor subtrees to skip for tests.
Example
Function Directory.Constructor is not accessible from the go module
Function Directory.Constructor is not accessible from the go module
Function Directory.Constructor is not accessible from the go module
Function Directory.Constructor is not accessible from the go module

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
versionString -Go version used for the default Go base image.
baseContainer -Base image used for Go test, generate, and helper containers. Mutually exclusive with version.
includeExtraFiles[String ! ] -Extra workspace-root include patterns mounted for each module's Go commands. Use this for fixtures, generator inputs, or other files not covered by the built-in Go patterns.
skipLint[String ! ] -Workspace-relative module roots or ancestor subtrees to skip for lint checks.
skipTest[String ! ] -Workspace-relative module roots or ancestor subtrees to skip for tests.
skipGenerate[String ! ] -Workspace-relative module roots or ancestor subtrees to skip for go generate.
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
func (m *MyModule) Example() *dagger.Go  {
	return dag.
			Go()
}
@function
def example() -> dagger.Go:
	return (
		dag.go()
	)
@func()
example(): Go {
	return dag
		.go()
}

Entrypoint

Return Type
Module !
Arguments
NameTypeDefault ValueDescription
pathString !-Workspace-relative path of this module root.
versionString -Go version configured on the root Go module. Null when a custom base is set.
baseImageContainer !-Base image used by this module's Go containers.
includeExtraFiles[String ! ] !-Extra workspace-root include patterns mounted for this module's Go commands.
skipLintPaths[String ! ] !-Workspace-relative module roots or ancestor subtrees to skip for lint checks.
skipTestPaths[String ! ] !-Workspace-relative module roots or ancestor subtrees to skip for tests.
skipGeneratePaths[String ! ] !-Workspace-relative module roots or ancestor subtrees to skip for go generate.
Example
Function Module.Constructor is not accessible from the go module
Function Module.Constructor is not accessible from the go module
Function Module.Constructor is not accessible from the go module
Function Module.Constructor is not accessible from the go module

Types

Directory 🔗

A workspace directory containing Go test files.

path() 🔗

Workspace-relative path of this directory.

Return Type
String !
Example
Function GoDirectory.path is not accessible from the go module
Function GoDirectory.path is not accessible from the go module
Function GoDirectory.path is not accessible from the go module
Function GoDirectory.path is not accessible from the go module

execute() 🔗

Run Go tests in this directory.

Return Type
Void !
Example
Function GoDirectory.execute is not accessible from the go module
Function GoDirectory.execute is not accessible from the go module
Function GoDirectory.execute is not accessible from the go module
Function GoDirectory.execute is not accessible from the go module

Go 🔗

A Dagger module for Go - a programming language for building simple, secure, scalable systems. https://dagger.io https://golang.org

version() 🔗

Go version used for the default Go base image. Null when a custom base is set.

Return Type
String 
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 version
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			Version(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.version()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.version()
}

base() 🔗

Base image used for Go test, generate, and helper containers.

Return Type
Container !
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 base
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Go().
			Base()
}
@function
def example() -> dagger.Container:
	return (
		dag.go()
		.base()
	)
@func()
example(): Container {
	return dag
		.go()
		.base()
}

includeExtraFiles() 🔗

Extra workspace-root include patterns mounted for each module’s Go commands. Use this for fixtures, generator inputs, or other files not covered by the built-in Go patterns.

Return Type
[String ! ] !
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 include-extra-files
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			IncludeExtraFiles(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.include_extra_files()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.includeExtraFiles()
}

skipLint() 🔗

Workspace-relative module roots or ancestor subtrees to skip for lint checks.

Return Type
[String ! ] !
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 skip-lint
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			SkipLint(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.skip_lint()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.skipLint()
}

skipTest() 🔗

Workspace-relative module roots or ancestor subtrees to skip for tests.

Return Type
[String ! ] !
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 skip-test
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			SkipTest(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.skip_test()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.skipTest()
}

skipGenerate() 🔗

Workspace-relative module roots or ancestor subtrees to skip for go generate.

Return Type
[String ! ] !
Example
dagger -m github.com/dagger/go@26d40e969f90d1aa2284e6d6b9636fec0e3c4e4c call \
 skip-generate
func (m *MyModule) Example(ctx context.Context) []string  {
	return dag.
			Go().
			SkipGenerate(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.go()
		.skip_generate()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.go()
		.skipGenerate()
}

modules() 🔗

Return every Go module discovered from workspace go.mod files. Optional include/exclude patterns filter discovered module root directories.

Return Type
[Module ! ] !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
include[String ! ] -No description provided
exclude[String ! ] -No description provided
includeSkipLintBoolean -No description provided
includeSkipTestBoolean -No description provided
includeSkipGenerateBoolean -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example() []*dagger.GoModule  {
	return dag.
			Go().
			Modules()
}
@function
def example() -> List[dagger.GoModule]:
	return (
		dag.go()
		.modules()
	)
@func()
example(): GoModule[] {
	return dag
		.go()
		.modules()
}

module() 🔗

Return the Go module containing a workspace path.

By default, path may be a module root or a directory inside a module. Set findUp to false when path is already a module root and no lookup is needed.

Return Type
Module !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
pathString !-No description provided
findUpBoolean -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) *dagger.GoModule  {
	return dag.
			Go().
			Module(path)
}
@function
def example(path: str) -> dagger.GoModule:
	return (
		dag.go()
		.module(path)
	)
@func()
example(path: string): GoModule {
	return dag
		.go()
		.module(path)
}

lintAll() 🔗

Run golangci-lint in every discovered Go module. Modules configured to skip lint are skipped.

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context)   {
	return dag.
			Go().
			LintAll(ctx)
}
@function
async def example() -> None:
	return await (
		dag.go()
		.lint_all()
	)
@func()
async example(): Promise<void> {
	return dag
		.go()
		.lintAll()
}

testAll() 🔗

Run tests in every discovered Go module. Modules configured to skip tests are skipped.

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context)   {
	return dag.
			Go().
			TestAll(ctx)
}
@function
async def example() -> None:
	return await (
		dag.go()
		.test_all()
	)
@func()
async example(): Promise<void> {
	return dag
		.go()
		.testAll()
}

generateAll() 🔗

Run go generate in every discovered Go module. Modules configured to skip generate, or without go:generate directives, are skipped.

Return Type
Changeset !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example() *dagger.Changeset  {
	return dag.
			Go().
			GenerateAll()
}
@function
def example() -> dagger.Changeset:
	return (
		dag.go()
		.generate_all()
	)
@func()
example(): Changeset {
	return dag
		.go()
		.generateAll()
}

Module 🔗

A Go module rooted at a workspace-relative path.

path() 🔗

Workspace-relative path of this module root.

Return Type
String !
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) string  {
	return dag.
			Go().
			Module(path).
			Path(ctx)
}
@function
async def example(path: str) -> str:
	return await (
		dag.go()
		.module(path)
		.path()
	)
@func()
async example(path: string): Promise<string> {
	return dag
		.go()
		.module(path)
		.path()
}

version() 🔗

Go version configured on the root Go module. Null when a custom base is set.

Return Type
String 
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) string  {
	return dag.
			Go().
			Module(path).
			Version(ctx)
}
@function
async def example(path: str) -> str:
	return await (
		dag.go()
		.module(path)
		.version()
	)
@func()
async example(path: string): Promise<string> {
	return dag
		.go()
		.module(path)
		.version()
}

includeExtraFiles() 🔗

Extra workspace-root include patterns mounted for this module’s Go commands.

Return Type
[String ! ] !
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) []string  {
	return dag.
			Go().
			Module(path).
			IncludeExtraFiles(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include_extra_files()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.includeExtraFiles()
}

skipLint() 🔗

Whether this module or an ancestor subtree is configured to skip lint.

Return Type
Boolean !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) bool  {
	return dag.
			Go().
			Module(path).
			SkipLint(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.skip_lint()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.skipLint()
}

skipTest() 🔗

Whether this module or an ancestor subtree is configured to skip tests.

Return Type
Boolean !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) bool  {
	return dag.
			Go().
			Module(path).
			SkipTest(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.skip_test()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.skipTest()
}

skipGenerate() 🔗

Whether this module or an ancestor subtree is configured to skip go generate.

Return Type
Boolean !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) bool  {
	return dag.
			Go().
			Module(path).
			SkipGenerate(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.skip_generate()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.skipGenerate()
}

hasGenerateDirectives() 🔗

Whether this module’s Go files contain a go:generate directive.

Return Type
Boolean !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) bool  {
	return dag.
			Go().
			Module(path).
			HasGenerateDirectives(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.has_generate_directives()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.hasGenerateDirectives()
}

includeDiscovered() 🔗

Additional workspace include patterns discovered by scanning Go directives and local go.mod replaces reachable from this module’s include graph. With no include flags, defaults to test inputs.

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
lintBoolean -No description provided
testBoolean -No description provided
generateBoolean -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) []string  {
	return dag.
			Go().
			Module(path).
			IncludeDiscovered(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include_discovered()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.includeDiscovered()
}

testDirectories() 🔗

Directories in this module containing Go test files.

Return Type
[Directory ! ] !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) []*dagger.GoDirectory  {
	return dag.
			Go().
			Module(path).
			TestDirectories()
}
@function
def example(path: str) -> List[dagger.GoDirectory]:
	return (
		dag.go()
		.module(path)
		.test_directories()
	)
@func()
example(path: string): GoDirectory[] {
	return dag
		.go()
		.module(path)
		.testDirectories()
}

includeBase() 🔗

Built-in workspace include patterns for this module’s own Go source files.

Return Type
[String ! ] !
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) []string  {
	return dag.
			Go().
			Module(path).
			IncludeBase(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include_base()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.includeBase()
}

include() 🔗

Final workspace include patterns used to build this module’s source directory. With no include flags, defaults to test inputs.

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
lintBoolean -No description provided
testBoolean -No description provided
generateBoolean -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string) []string  {
	return dag.
			Go().
			Module(path).
			Include(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.include()
}

source() 🔗

Workspace source mounted for this module’s Go commands. With no include flags, defaults to test inputs.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
lintBoolean -No description provided
testBoolean -No description provided
generateBoolean -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) *dagger.Directory  {
	return dag.
			Go().
			Module(path).
			Source()
}
@function
def example(path: str) -> dagger.Directory:
	return (
		dag.go()
		.module(path)
		.source()
	)
@func()
example(path: string): Directory {
	return dag
		.go()
		.module(path)
		.source()
}

testData() 🔗

Workspace testdata directories mounted while testing this module.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) *dagger.Directory  {
	return dag.
			Go().
			Module(path).
			TestData()
}
@function
def example(path: str) -> dagger.Directory:
	return (
		dag.go()
		.module(path)
		.test_data()
	)
@func()
example(path: string): Directory {
	return dag
		.go()
		.module(path)
		.testData()
}

base() 🔗

Base Go container before source files and commands are added.

Return Type
Container !
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) *dagger.Container  {
	return dag.
			Go().
			Module(path).
			Base()
}
@function
def example(path: str) -> dagger.Container:
	return (
		dag.go()
		.module(path)
		.base()
	)
@func()
example(path: string): Container {
	return dag
		.go()
		.module(path)
		.base()
}

lint() 🔗

Run golangci-lint in this module. If this module is configured to skip lint, no lint check is run.

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string)   {
	return dag.
			Go().
			Module(path).
			Lint(ctx)
}
@function
async def example(path: str) -> None:
	return await (
		dag.go()
		.module(path)
		.lint()
	)
@func()
async example(path: string): Promise<void> {
	return dag
		.go()
		.module(path)
		.lint()
}

test() 🔗

Run tests in this module. If this module is configured to skip tests, no tests are run.

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(ctx context.Context, path string)   {
	return dag.
			Go().
			Module(path).
			Test(ctx)
}
@function
async def example(path: str) -> None:
	return await (
		dag.go()
		.module(path)
		.test()
	)
@func()
async example(path: string): Promise<void> {
	return dag
		.go()
		.module(path)
		.test()
}

generate() 🔗

Changes made by running go generate in this module. If this module is configured to skip generate or no go:generate directives are found, the changeset is empty.

Return Type
Changeset !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -No description provided
Example
echo 'Custom types are not supported in shell examples'
func (m *MyModule) Example(path string) *dagger.Changeset  {
	return dag.
			Go().
			Module(path).
			Generate()
}
@function
def example(path: str) -> dagger.Changeset:
	return (
		dag.go()
		.module(path)
		.generate()
	)
@func()
example(path: string): Changeset {
	return dag
		.go()
		.module(path)
		.generate()
}