Dagger
Search

go

No long description provided.

Installation

dagger install github.com/dagger/go@5557eb305f30234285b374f89f7b338f47e48228

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.
lint[String ! ] -Module roots to lint, as gitignore-style globs: a bare glob includes, a "!"-prefixed glob excludes. Defaults to every module ("**"). For example ["**", "!docs"] lints all but the docs subtree; ["e2e/**"] lints only e2e.
test[String ! ] -Module roots to test. Same gitignore-style globs as `lint`.
generate[String ! ] -Module roots to run go generate in. Same gitignore-style globs as `lint`.
Example
dagger -m github.com/dagger/go@5557eb305f30234285b374f89f7b338f47e48228 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
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.
testPatterns[String ! ] !-Gitignore-style globs selecting which module roots to test.
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
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.
lintPatterns[String ! ] !-Gitignore-style globs selecting which module roots to lint.
testPatterns[String ! ] !-Gitignore-style globs selecting which module roots to test.
generatePatterns[String ! ] !-Gitignore-style globs selecting which module roots to run go generate in.
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

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@5557eb305f30234285b374f89f7b338f47e48228 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@5557eb305f30234285b374f89f7b338f47e48228 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@5557eb305f30234285b374f89f7b338f47e48228 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()
}

lint() 🔗

Module roots to lint, as gitignore-style globs (“!” excludes).

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

test() 🔗

Module roots to test, as gitignore-style globs (“!” excludes).

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

generate() 🔗

Module roots to run go generate in, as gitignore-style globs (“!” excludes).

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

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()
}

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

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 falls outside the configured lint selection.

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 falls outside the configured test selection.

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 falls outside the configured go generate selection.

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()
}