Dagger
Search

go

No long description provided.

Installation

dagger install github.com/dagger/go@7b41fc08098ae47a990e9ad8e5403d0001644152

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.
goModulesMustOptInBoolean -Require each Go module to contain the opt-in marker before tests or generate run.
goModuleOptInFilenameString -Opt-in marker filename checked at each Go module root. Only used when goModulesMustOptIn is true.
Example
dagger -m github.com/dagger/go@7b41fc08098ae47a990e9ad8e5403d0001644152 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 to use.
includeExtraFiles[String ! ] !-Extra workspace files to include when running Go commands.
mustOptInBoolean !-Whether this module requires an opt-in marker before tests or generate run.
optInFilenameString !-Marker filename used when this module must opt 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

goModulesMustOptIn() 🔗

Require each Go module to contain the opt-in marker before tests or generate run.

Return Type
Boolean !
Example
dagger -m github.com/dagger/go@7b41fc08098ae47a990e9ad8e5403d0001644152 call \
 go-modules-must-opt-in
func (m *MyModule) Example(ctx context.Context) bool  {
	return dag.
			Go().
			GoModulesMustOptIn(ctx)
}
@function
async def example() -> bool:
	return await (
		dag.go()
		.go_modules_must_opt_in()
	)
@func()
async example(): Promise<boolean> {
	return dag
		.go()
		.goModulesMustOptIn()
}

goModuleOptInFilename() 🔗

Opt-in marker filename checked at each Go module root. Only used when goModulesMustOptIn is true.

Return Type
String !
Example
dagger -m github.com/dagger/go@7b41fc08098ae47a990e9ad8e5403d0001644152 call \
 go-module-opt-in-filename
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Go().
			GoModuleOptInFilename(ctx)
}
@function
async def example() -> str:
	return await (
		dag.go()
		.go_module_opt_in_filename()
	)
@func()
async example(): Promise<string> {
	return dag
		.go()
		.goModuleOptInFilename()
}

version() 🔗

Go version used for test and generate commands.

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

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

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

testAll() 🔗

Run tests in every discovered Go module. When opt-in is required, modules without the 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()
}

generate() 🔗

Run go generate in every discovered Go module. When opt-in is required, modules without the marker 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().
			Generate()
}
@function
def example() -> dagger.Changeset:
	return (
		dag.go()
		.generate()
	)
@func()
example(): Changeset {
	return dag
		.go()
		.generate()
}

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

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

mustOptIn() 🔗

Whether this module requires an opt-in marker before tests or generate run.

Return Type
Boolean !
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).
			MustOptIn(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.must_opt_in()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.mustOptIn()
}

includeFromGoDirectives() 🔗

Workspace include patterns discovered from go:embed and workspace:include directives in this module’s Go files.

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).
			IncludeFromGoDirectives(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include_from_go_directives()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.includeFromGoDirectives()
}

optedIn() 🔗

Whether this module root contains the configured opt-in 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).
			OptedIn(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.opted_in()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.optedIn()
}

generate() 🔗

Module directory after running go generate. When opt-in is required and this module has no marker, the source is returned unchanged.

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).
			Generate()
}
@function
def example(path: str) -> dagger.Directory:
	return (
		dag.go()
		.module(path)
		.generate()
	)
@func()
example(path: string): Directory {
	return dag
		.go()
		.module(path)
		.generate()
}

includeFromGoModReplace() 🔗

Workspace include patterns discovered from this module’s local go.mod replace directives.

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).
			IncludeFromGoModReplace(ctx)
}
@function
async def example(path: str) -> List[str]:
	return await (
		dag.go()
		.module(path)
		.include_from_go_mod_replace()
	)
@func()
async example(path: string): Promise<string[]> {
	return dag
		.go()
		.module(path)
		.includeFromGoModReplace()
}

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

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

shouldIgnore() 🔗

Whether tests and generate should skip this module under the current opt-in policy.

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).
			ShouldIgnore(ctx)
}
@function
async def example(path: str) -> bool:
	return await (
		dag.go()
		.module(path)
		.should_ignore()
	)
@func()
async example(path: string): Promise<boolean> {
	return dag
		.go()
		.module(path)
		.shouldIgnore()
}

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

test() 🔗

Run tests in this module. When opt-in is required and this module has no marker, 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, 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()
}