Dagger
Search

go

No long description provided.

Installation

dagger install github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11

Entrypoint

Return Type
Module !
Arguments
NameTypeDefault ValueDescription
pathString !-Workspace-relative path of this module root.
versionString !-Go version used by this module's test and generate containers.
includeExtraFiles[String ! ] !-Extra workspace-root include patterns mounted for this module's Go commands.
skipLintFilenameString !-Marker filename that skips lint checks when found at or above this module root.
skipTestFilenameString !-Marker filename that skips tests when found at or above this module root.
skipGenerateFilenameString !-Marker filename that skips go generate when found at or above this module root.
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

Entrypoint

Return Type
Go !
Arguments
NameTypeDefault ValueDescription
versionString -Go version used for test and generate commands.
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.
skipLintFilenameString -Marker filename that skips lint checks when found at or above a Go module root.
skipTestFilenameString -Marker filename that skips tests when found at or above a Go module root.
skipGenerateFilenameString -Marker filename that skips go generate when found at or above a Go module root.
Example
dagger -m github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11 call \
func (m *MyModule) Example() *dagger.Go  {
	return dag.
			Go()
}
@function
def example() -> dagger.Go:
	return (
		dag.go()
	)
@func()
example(): Go {
	return dag
		.go()
}

Types

Module 🔗

A Go module rooted at a workspace-relative path.

version() 🔗

Go version used by this module’s test and generate containers.

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

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

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

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

test() 🔗

Run tests in this module. If the test skip marker is present, 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()
}

include() 🔗

Final workspace include patterns used to build this module’s source directory.

Return Type
[String ! ] !
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) []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.

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

skipTest() 🔗

Whether this module or an ancestor contains the configured test skip marker.

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

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 layers.

Return Type
[String ! ] !
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) []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()
}

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 the lint skip marker is present, 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()
}

generate() 🔗

Changes made by running go generate in this module. If the generate skip marker is present 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()
}

skipLint() 🔗

Whether this module or an ancestor contains the configured lint skip marker.

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

skipGenerate() 🔗

Whether this module or an ancestor contains the configured generate skip marker.

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

Go 🔗

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

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@427d2cde972060a3e0b2b3be4ae46e4fa665da11 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()
}

skipLintFilename() 🔗

Marker filename that skips lint checks when found at or above a Go module root.

Return Type
String !
Example
dagger -m github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11 call \
 skip-lint-filename
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			SkipLintFilename(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.skip_lint_filename()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.skipLintFilename()
}

skipTestFilename() 🔗

Marker filename that skips tests when found at or above a Go module root.

Return Type
String !
Example
dagger -m github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11 call \
 skip-test-filename
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			SkipTestFilename(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.skip_test_filename()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.skipTestFilename()
}

skipGenerateFilename() 🔗

Marker filename that skips go generate when found at or above a Go module root.

Return Type
String !
Example
dagger -m github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11 call \
 skip-generate-filename
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			SkipGenerateFilename(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.skip_generate_filename()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.skipGenerateFilename()
}

version() 🔗

Go version used for test and generate commands.

Return Type
String !
Example
dagger -m github.com/dagger/go@427d2cde972060a3e0b2b3be4ae46e4fa665da11 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()
}

generateAll() 🔗

Run go generate in every discovered Go module. Modules with the generate skip marker, 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()
}

modules() 🔗

Return every Go module discovered from workspace go.mod files.

Return Type
[Module ! ] !
Arguments
NameTypeDefault ValueDescription
wsWorkspace -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 with the lint skip marker 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 with the test skip marker 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()
}