Dagger
Search

gotoolbox

This module has been generated via dagger init and serves as a reference to
basic module structure as you get started with Dagger. The module demonstrates
usage of arguments and return types using simple echo and grep commands. The functions
can be called from the dagger CLI or from one of the SDKs.

The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
Example (OpenTerminal)
no available example in current language
// Gotoolbox_OpenTerminal demonstrates how to open an interactive terminal session
// within a Gotoolbox module container.
//
// This function showcases the initialization and configuration of a
// Gotoolbox module container using various options like enabling Cgo,
// utilizing build cache, and including a GCC compiler.
//
// Parameters:
//   - None
//
// Returns:
//   - *dagger.Container: A configured Dagger container with an open terminal.
//
// Usage:
//
//	This function can be used to interactively debug or inspect the
//	container environment during test execution.
func (m *Go) Gotoolbox_OpenTerminal() *dagger.Container {
	// Configure the Gotoolbox module container with necessary options
	targetModule := dag.Gotoolbox()

	// Retrieve and discard standard output
	_, _ = targetModule.Ctr().
		Stdout(context.Background())

	// Open and return the terminal session in the configured container
	return targetModule.Ctr().
		Terminal()
}
no available example in current language
no available example in current language
Example (PassedEnvVars)
no available example in current language
// Gotoolbox_PassedEnvVars demonstrates how to pass environment variables to the Gotoolbox module.
//
// This method configures a Gotoolbox module to use specific environment variables from the host.
func (m *Go) Gotoolbox_PassedEnvVars(ctx context.Context) error {
	targetModule := dag.Gotoolbox(dagger.GotoolboxOpts{
		EnvVarsFromHost: []string{"SOMETHING=SOMETHING,SOMETHING=SOMETHING"},
	})

	out, err := targetModule.Ctr().
		WithExec([]string{"printenv"}).
		Stdout(ctx)

	if err != nil {
		return fmt.Errorf("failed when executing printenv: %w", err)
	}

	if out == "" {
		return errEnvVarsEmpty
	}

	if !strings.Contains(out, "SOMETHING") {
		return errEnvVarsDontMatch
	}

	return nil
}
no available example in current language
no available example in current language
Example (CreateContainer)
no available example in current language
// Gotoolbox_CreateContainer initializes and returns a configured Dagger container.
//
// This method exemplifies the setup of a container within the Gotoolbox module using the source directory.
//
// Parameters:
//   - ctx: The context for controlling the function's timeout and cancellation.
//
// Returns:
//   - A configured Dagger container if successful, or an error if the process fails.
//
// Steps Involved:
//  1. Configure the Gotoolbox module with the source directory.
//  2. Run a command inside the container to check the OS information.
func (m *Go) Gotoolbox_CreateContainer(ctx context.Context) (*dagger.Container, error) {
	targetModule := dag.
		Gotoolbox().
		WithSource(m.TestDir)

	// Get the OS or container information
	_, err := targetModule.
		Ctr().WithExec([]string{"uname"}).
		Stdout(ctx)

	if err != nil {
		return nil, fmt.Errorf("failed to get OS information: %w", err)
	}

	return targetModule.Ctr(), nil
}
no available example in current language
no available example in current language
Example (RunArbitraryCommand)
no available example in current language
// Gotoolbox_RunArbitraryCommand runs an arbitrary shell command in the test container.
//
// This function demonstrates how to execute a shell command within the container
// using the Gotoolbox module.
//
// Parameters:
//
//	ctx - context for controlling the function lifetime.
//
// Returns:
//
//	A string containing the output of the executed command, or an error if the command fails or if the output is empty.
func (m *Go) Gotoolbox_RunArbitraryCommand(ctx context.Context) (string, error) {
	targetModule := dag.Gotoolbox().WithSource(m.TestDir)

	// Execute the 'ls -l' command
	out, err := targetModule.
		Ctr().
		WithExec([]string{"ls", "-l"}).
		Stdout(ctx)

	if err != nil {
		return "", fmt.Errorf("failed to run shell command: %w", err)
	}

	if out == "" {
		return "", errExpectedFoldersNotFound
	}

	return out, nil
}
no available example in current language
no available example in current language
Example (CreateNetRcFileForGithub)
no available example in current language
// Gotoolbox_CreateNetRcFileForGithub creates and configures a .netrc file for GitHub authentication.
//
// This method exemplifies the creation of a .netrc file with credentials for accessing GitHub,
// and demonstrates how to pass this file as a secret to the Gotoolbox module.
//
// Parameters:
//   - ctx: The context for controlling the function's timeout and cancellation.
//
// Returns:
//   - A configured Container with the .netrc file set as a secret, or an error if the process fails.
//
// Steps Involved:
//  1. Define GitHub password as a secret.
//  2. Configure the Gotoolbox module to use the .netrc file with the provided credentials.
//  3. Run a command inside the container to verify the .netrc file's contents.
func (m *Go) Gotoolbox_CreateNetRcFileForGithub(ctx context.Context) (*dagger.Container, error) {
	passwordAsSecret := dag.SetSecret("mysecret", "ohboywhatapassword")

	// Configure it for GitHub
	targetModule := dag.Gotoolbox().
		WithNewNetrcFileAsSecretGitHub("supersecretuser", passwordAsSecret)

	// Check if the .netrc file is created correctly
	out, err := targetModule.
		Ctr().
		WithExec([]string{"cat", "/root/.netrc"}).
		Stdout(ctx)

	if err != nil {
		return nil, fmt.Errorf("failed to get netrc file configured for github: %w", err)
	}

	expectedContent := "machine github.com\nlogin supersecretuser\npassword ohboywhatapassword"
	if !strings.Contains(out, expectedContent) {
		return nil, errNetRCFileNotFound
	}

	return targetModule.Ctr(), nil
}
no available example in current language
no available example in current language

Installation

dagger install github.com/Excoriate/daggerverse/gotoolbox@v0.3.0

Entrypoint

Return Type
Gotoolbox !
Arguments
NameTypeDescription
versionString version is the version of the container image to use. Consider that this Dagger module uses al alpine-based image.
ctrContainer ctr is the container to use as a base container.
envVarsFromHost[String ! ] envVarsFromHost is a list of environment variables to pass from the host to the container in a slice of strings.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
}

Types

Gotoolbox 🔗

Gotoolbox is a Dagger module. This module is used to create and manage containers.

ctr() 🔗

Ctr is the container to use as a base container.

Return Type
Container !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 ctr
func (m *myModule) example() *Container  {
	return dag.
			Gotoolbox().
			Ctr()
}
@function
def example() -> dagger.Container:
	return (
		dag.gotoolbox()
		.ctr()
	)
@func()
example(): Container {
	return dag
		.gotoolbox()
		.ctr()
}

withNewNetrcFileGitHub() 🔗

WithNewNetrcFileGitHub creates a new .netrc file with the GitHub credentials.

The .netrc file is created in the root directory of the container.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordString !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-new-netrc-file-git-hub --username string --password string
func (m *myModule) example(username string, password string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithNewNetrcFileGitHub(username, password)
}
@function
def example(username: str, password: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_new_netrc_file_git_hub(username, password)
	)
@func()
example(username: string, password: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withNewNetrcFileGitHub(username, password)
}

withNewNetrcFileAsSecretGitHub() 🔗

WithNewNetrcFileAsSecretGitHub creates a new .netrc file with the GitHub credentials.

The .netrc file is created in the root directory of the container. The argument ‘password’ is a secret that is not exposed in the logs.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordSecret !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-new-netrc-file-as-secret-git-hub --username string --password env:MYSECRET
func (m *myModule) example(username string, password *Secret) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithNewNetrcFileAsSecretGitHub(username, password)
}
@function
def example(username: str, password: dagger.Secret) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_new_netrc_file_as_secret_git_hub(username, password)
	)
@func()
example(username: string, password: Secret): Gotoolbox {
	return dag
		.gotoolbox()
		.withNewNetrcFileAsSecretGitHub(username, password)
}

withNewNetrcFileGitLab() 🔗

WithNewNetrcFileGitLab creates a new .netrc file with the GitLab credentials.

The .netrc file is created in the root directory of the container.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordString !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-new-netrc-file-git-lab --username string --password string
func (m *myModule) example(username string, password string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithNewNetrcFileGitLab(username, password)
}
@function
def example(username: str, password: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_new_netrc_file_git_lab(username, password)
	)
@func()
example(username: string, password: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withNewNetrcFileGitLab(username, password)
}

withNewNetrcFileAsSecretGitLab() 🔗

WithNewNetrcFileAsSecretGitLab creates a new .netrc file with the GitLab credentials.

The .netrc file is created in the root directory of the container. The argument ‘password’ is a secret that is not exposed in the logs.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordSecret !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-new-netrc-file-as-secret-git-lab --username string --password env:MYSECRET
func (m *myModule) example(username string, password *Secret) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithNewNetrcFileAsSecretGitLab(username, password)
}
@function
def example(username: str, password: dagger.Secret) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_new_netrc_file_as_secret_git_lab(username, password)
	)
@func()
example(username: string, password: Secret): Gotoolbox {
	return dag
		.gotoolbox()
		.withNewNetrcFileAsSecretGitLab(username, password)
}

withGitInAlpineContainer() 🔗

WithGitInAlpineContainer installs Git in the golang/alpine container.

It installs Git in the golang/alpine container.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-git-in-alpine-container
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGitInAlpineContainer()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_git_in_alpine_container()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGitInAlpineContainer()
}

withUtilitiesInAlpineContainer() 🔗

WithUtilitiesInAlpineContainer installs common utilities in the golang/alpine container.

It installs utilities such as curl, wget, and others that are commonly used.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-utilities-in-alpine-container
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithUtilitiesInAlpineContainer()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_utilities_in_alpine_container()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withUtilitiesInAlpineContainer()
}

runGoCmd() 🔗

RunGoCMD runs a Go command within a given context.

cmd is the Go command to run, everything after the ‘go’ command. src is the optional source directory for the container.

It returns the standard output of the executed command or an error if something goes wrong.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
cmd[String ! ] !-cmd is the Go command to run, everything after the 'go' command.
srcDirectory -src is the optional source directory for the container.
testDirString -testDir is the optional test directory for the container. If you are passing a source code directory in the 'src' parameter, you can pass the test directory to run the tests.
platformScalar -platform is the optional platform to run the Go command.
envVariables[String ! ] -envVariables are the optional environment variables to set for the container. the envVariables are set in a form of a string array, where each element is a key-value pair, separated by coma. E.g. ["KEY=value", "KEY2=value2"].
enableCacheBusterBoolean -enableCacheBuster is a flag to force the cache to bust.
enableCgoBoolean -enableCgo is a flag to enable CGO.
enableGoModCacheBoolean -enableGoModCache is a flag to enable Go mod cache.
enableGoBuildCacheBoolean -enableGoBuildCache is a flag to enable Go build cache.
installPkgs[String ! ] -installPkgs are the packages to install.
enableGoGcccompilerBoolean -enableGoGCCCompiler is a flag to enable GoGCCCompiler.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 run-go-cmd --cmd string1 --cmd string2
func (m *myModule) example(ctx context.Context, cmd []string) string  {
	return dag.
			Gotoolbox().
			RunGoCmd(ctx, cmd)
}
@function
async def example(cmd: List[str]) -> str:
	return await (
		dag.gotoolbox()
		.run_go_cmd(cmd)
	)
@func()
async example(cmd: string[]): Promise<string> {
	return dag
		.gotoolbox()
		.runGoCmd(cmd)
}

runAnyCmd() 🔗

RunAnyCmd runs a command within a given context.

cmd is the command to run, with the first element being the command and the rest being arguments. src is the optional source directory for the container.

It returns the standard output of the executed command or an error if something goes wrong.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
cmd[String ! ] !-cmd is the command to run, with the first element being the command and the rest being arguments.
srcDirectory -src is the optional source directory for the container.
workDirString -workDir is the optional working directory for the container. If you are passing a source code directory in the 'src' parameter, you can pass the working directory to run the command.
platformScalar -platform is the optional platform to run the command.
envVariables[String ! ] -envVariables are the optional environment variables to set for the container. the envVariables are set in a form of a string array, where each element is a key-value pair, separated by an equals sign. E.g. ["KEY=value", "KEY2=value2"].
enableCacheBusterBoolean -enableCacheBuster is a flag to force the cache to bust.
installPkgs[String ! ] -installPkgs are the packages to install.
enableGoGcccompilerBoolean -enableGoGCCCompiler is a flag to enable GoGCCCompiler.
enableGoModCacheBoolean -enableGoModCache is a flag to enable Go mod cache.
enableGoBuildCacheBoolean -enableGoBuildCache is a flag to enable Go build cache.
enableGoReleaserBoolean -enableGoReleaser is a flag to enable GoReleaser.
enableGolangCilintBoolean -enableGolangCILint is a flag to enable GolangCI-Lint.
enableGoTestSumBoolean -enableGoTestSum is a flag to enable Go test summaries.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 run-any-cmd --cmd string1 --cmd string2
func (m *myModule) example(ctx context.Context, cmd []string) string  {
	return dag.
			Gotoolbox().
			RunAnyCmd(ctx, cmd)
}
@function
async def example(cmd: List[str]) -> str:
	return await (
		dag.gotoolbox()
		.run_any_cmd(cmd)
	)
@func()
async example(cmd: string[]): Promise<string> {
	return dag
		.gotoolbox()
		.runAnyCmd(cmd)
}

withGoPlatform() 🔗

WithGoPlatform sets the Go environment variables for the target platform.

platform is the target platform specified in the format “[os]/[platform]/[version]”. For example, “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”. If the platform is not provided, it defaults to “linux/amd64”.

Params: - platform (dagger.Platform): The target platform.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
platformScalar -platform is the target platform specified in the format "[os]/[platform]/[version]". For example, "darwin/arm64/v7", "windows/amd64", "linux/arm64". If the platform is not provided, it defaults to "linux/amd64".
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-platform
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoPlatform()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_platform()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoPlatform()
}

withGoCgoEnabled() 🔗

WithGoCgoEnabled enables CGO for the container environment.

When CGO is enabled, the Go toolchain will allow the use of cgo, which means it can link against C libraries and send code to the C compiler.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-cgo-enabled
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoCgoEnabled()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_cgo_enabled()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoCgoEnabled()
}

withCgoDisabled() 🔗

WithCgoDisabled disables CGO for the container environment.

When CGO is disabled, the Go toolchain will not permit the use of cgo, which means it will not link against C libraries or send code to the C compiler. This can be beneficial for creating fully static binaries or for environments where C dependencies are not available.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-cgo-disabled
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithCgoDisabled()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_cgo_disabled()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withCgoDisabled()
}

withGoBuildCache() 🔗

WithGoBuildCache configures a Go build cache for the container environment.

This method sets up the cache volume for Go build artifacts, which speeds up the build process by reusing previously compiled packages and dependencies.

Params: - cacheRoot (string) +optional: The path to the cache volume’s root. If not provided, it defaults to “/root/.cache/go-build”. - cache (*dagger.CacheVolume) +optional: The cache volume to use. If not provided, a default volume named “gobuildcache” is used. - source (*dagger.Directory) +optional: The directory to use as the source for the cache volume’s root. - sharing (dagger.CacheSharingMode) +optional: The sharing mode of the cache volume. If not provided, it defaults to “shared”.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
cacheRootString -cacheRoot is the path to the cache volume's root.
cacheCacheVolume -cache is the cache volume to use.
sourceDirectory -source is the identifier of the directory to use as the cache volume's root.
sharingEnum -sharing is the Sharing mode of the cache volume.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-build-cache
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoBuildCache()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_build_cache()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoBuildCache()
}

withGoModCache() 🔗

WithGoModCache configures a Go module cache for the container environment.

This method sets up the cache volume for Go modules, which speeds up the build process by reusing previously downloaded dependencies.

Params: - cacheRoot (string): The path to the cache volume’s root. If not provided, it defaults to “/go/pkg/mod”. - cache (*dagger.CacheVolume) +optional: The cache volume to use. If not provided, a default volume named “gomodcache” is used. - source (*dagger.Directory) +optional: The directory to use as the source for the cache volume’s root. - sharing (dagger.CacheSharingMode) +optional: The sharing mode of the cache volume. If not provided, it defaults to “shared”.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
cacheRootString -cacheRoot is the path to the cache volume's root.
cacheCacheVolume -cache is the cache volume to use.
sourceDirectory -source is the identifier of the directory to use as the cache volume's root.
sharingEnum -sharing is the Sharing mode of the cache volume.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-mod-cache
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoModCache()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_mod_cache()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoModCache()
}

withGoInstall() 🔗

WithGoInstall installs Go packages in the container environment.

This method uses the Go toolchain to install packages from specified URLs. It performs the equivalent of running “go install [url]” inside the container.

Params: - pkgs ([]string): A slice of URLs for the Go packages to install. These should be valid package URLs that the go install command can use.

Example:

Gotoolbox.WithGoInstall([]string{"github.com/Excoriate/daggerverse@latest", "github.com/another/package@v1.0"})

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
pkgs[String ! ] !-pkgs are the URLs of the packages to install.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-install --pkgs string1 --pkgs string2
func (m *myModule) example(pkgs []string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoInstall(pkgs)
}
@function
def example(pkgs: List[str]) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_install(pkgs)
	)
@func()
example(pkgs: string[]): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoInstall(pkgs)
}

withGoExec() 🔗

WithGoExec runs a Go command in the container environment.

This method allows you to execute arbitrary Go commands, such as “go build” or “go test”, for a specified platform. If no platform is provided, it defaults to “linux/amd64”.

Params: - args ([]string): The arguments to pass to the Go command. For example, [“build”, “./…”] to run a Go build command on all packages. - platform (dagger.Platform) +optional: The target platform specified in the format “[os]/[platform]/[version]”. For example, “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”. If the platform is not provided, it defaults to “linux/amd64”.

Example:

Gotoolbox.WithGoExec([]string{"build", "./..."}, "linux/amd64")

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
args[String ! ] !-args are the arguments to pass to the Go command.
platformScalar -platform is the target platform specified in the format "[os]/[platform]/[version]". For example, "darwin/arm64/v7", "windows/amd64", "linux/arm64". If the platform is not provided, it defaults to "linux/amd64".
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-exec --args string1 --args string2
func (m *myModule) example(args []string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoExec(args)
}
@function
def example(args: List[str]) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_exec(args)
	)
@func()
example(args: string[]): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoExec(args)
}

withGoBuild() 🔗

WithGoBuild configures and executes a Go build command within the container environment.

This method builds a Go package based on specified parameters such as package name, race detection, build flags, tags, and output binary name.

Params: - pkg (string) +optional: The Go package to compile. If empty, the package in the current directory is compiled. - race (bool) +optional: Enable data race detection if true. - ldflags ([]string) +optional: Arguments to pass on each go tool link invocation. - tags ([]string) +optional: A list of additional build tags to consider satisfied during the build. - trimpath (bool) +optional: Remove all file system paths from the resulting executable if true. - rawArgs ([]string) +optional: Additional arguments to pass to the build command. - platform (dagger.Platform) +optional: Target platform in “[os]/[platform]/[version]” format, defaults to “linux/amd64”. - output (string) +optional: The output binary name or path. - optimizeSize (bool) +optional: Optimize for size if true. - verbose (bool) +optional: Verbose output if true. - buildMode (string) +optional: Specify the build mode.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
pkgString -pkg is the Go package to compile.
raceBoolean -race enables data race detection.
ldflags[String ! ] -ldflags are arguments to pass on each go tool link invocation.
tags[String ! ] -tags are additional build tags to consider satisfied during the build.
trimpathBoolean -trimpath removes all file system paths from the resulting executable.
rawArgs[String ! ] -rawArgs are additional arguments to pass to the build command.
platformScalar -platform is the target platform in "[os]/[platform]/[version]" format, defaults to "linux/amd64".
outputString -output specifies the output binary name or path.
optimizeSizeBoolean -optimizeSize optimizes for size.
verboseBoolean -verbose enables verbose output.
buildModeString -buildMode specifies the build mode.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-build
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoBuild()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_build()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoBuild()
}

withGoPrivate() 🔗

WithGoPrivate configures the GOPRIVATE environment variable for the container environment.

This method sets the GOPRIVATE variable, which is used by the Go toolchain to identify private modules or repositories that should not be fetched from public proxies.

Parameters: - privateHost (string): The hostname of the private host for the Go packages or modules.

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
privateHostString !-privateHost is the hostname of the private host for the Go packages or modules.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-private --private-host string
func (m *myModule) example(privateHost string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoPrivate(privateHost)
}
@function
def example(private_host: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_private(private_host)
	)
@func()
example(privateHost: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoPrivate(privateHost)
}

withGoGcccompiler() 🔗

WithGoGCCCompiler installs the GCC compiler and development tools in the container environment.

This method uses the Alpine package manager (apk) to install the GCC compiler along with musl-dev, which is the development package of the standard C library on Alpine.

Example usage:

Gotoolbox.WithGCCCompiler()

Returns: - *Gotoolbox: A pointer to the updated Gotoolbox instance.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-gcccompiler
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoGcccompiler()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_gcccompiler()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoGcccompiler()
}

withGoTestSum() 🔗

WithGoTestSum installs the GoTestSum tool and optionally its dependency tparse in the container environment.

This method installs gotest.tools/gotestsum using the specified version, and optionally installs github.com/mfridman/tparse using a specified version, unless the skipTParse flag is set to true.

Parameters: - goTestSumVersion (string) +optional: The version of GoTestSum to use, e.g., “v0.8.0”. If empty, it defaults to “latest”. - tParseVersion (string) +optional: The version of TParse to use, e.g., “v0.8.0”. If empty, it defaults to the same version as goTestSumVersion. - skipTParse (bool) +optional: If true, TParse will not be installed. Default is false.

Example:

m := &ModuleTemplate{}
m.WithGoTestSum("v0.8.0", "v0.7.0", false)   // Install specific versions
m.WithGoTestSum("", "", true)                // Install latest version of GoTestSum and skip TParse

Returns: - *ModuleTemplate: A pointer to the updated ModuleTemplate instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
goTestSumVersionString -goTestSumVersion is the version of GoTestSum to use, e.g., "v0.8.0".
tParseVersionString -tParseVersion is the version of TParse to use, e.g., "v0.8.0".
skipTparseBoolean -skipTParse is a flag to indicate whether TParse should be skipped.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-test-sum
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoTestSum()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_test_sum()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoTestSum()
}

withGoReleaser() 🔗

WithGoReleaser installs the GoReleaser tool in the container environment.

This method installs goreleaser using the specified version. Check https://goreleaser.com/install/

Parameters: - version (string): The version of GoReleaser to use, e.g., “v2@latest”.

Example:

m := &ModuleTemplate{}
m.WithGoReleaser("v2.2.0")  // Install GoReleaser version 2.2.0

Returns: - *ModuleTemplate: A pointer to the updated ModuleTemplate instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
versionString -version is the version of GoReleaser to use, e.g., By default, it's set "v2@latest".
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-releaser
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoReleaser()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_releaser()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoReleaser()
}

withGoLint() 🔗

WithGoLint installs the GoLint tool in the container environment.

This method installs golangci-lint using the specified version.

Parameters: - version (string): The version of GoLint to use, e.g., “v1.60.1”.

Example:

m := &ModuleTemplate{}
m.WithGoLint("v1.60.1")  // Install GoLint version 1.60.1

Returns: - *ModuleTemplate: A pointer to the updated ModuleTemplate instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
versionString !-version is the version of GoLint to use, e.g., "v1.60.1".
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-go-lint --version string
func (m *myModule) example(version string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithGoLint(version)
}
@function
def example(version: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_go_lint(version)
	)
@func()
example(version: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withGoLint(version)
}

base() 🔗

Base sets the base image and version, and creates the base container.

The default image is “alpine/latest” and the default version is “latest”.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
imageUrlString !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 base --image-url string
func (m *myModule) example(imageUrl string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			Base(imageUrl)
}
@function
def example(image_url: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.base(image_url)
	)
@func()
example(imageUrl: string): Gotoolbox {
	return dag
		.gotoolbox()
		.base(imageUrl)
}

newGoServer() 🔗

NewGoServer initializes and returns a new instance of GoServer with the given service name and port.

Parameters:

serviceName string: The name of the service to be created (optional, defaults to “go-server”). port int: The port to expose from the service.

Returns:

*GoServer: An instance of GoServer configured with a container created from the default image and version.

Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
ctrContainer -ctr is the container to use as a base container. If it's not set, it'll create a new container.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
}

downloadFile() 🔗

DownloadFile downloads a file from the specified URL.

Parameters: - url: The URL of the file to download. - destFileName: The name of the file to download. Optional parameter. If not set, it’ll default to the basename of the URL.

Returns: - *dagger.File: The downloaded file.

Functionality:

This method downloads a file from the provided URL. If the destination file name is not specified, it defaults to the basename of the URL. The downloaded file is then returned as a *dagger.File.

Return Type
File !
Arguments
NameTypeDefault ValueDescription
urlString !-url is the URL of the file to download.
destFileNameString -destFileName is the name of the file to download. If not set, it'll default to the basename of the URL.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 download-file --url string
func (m *myModule) example(url string) *File  {
	return dag.
			Gotoolbox().
			DownloadFile(url)
}
@function
def example(url: str) -> dagger.File:
	return (
		dag.gotoolbox()
		.download_file(url)
	)
@func()
example(url: string): File {
	return dag
		.gotoolbox()
		.downloadFile(url)
}

cloneGitRepo() 🔗

CloneGitRepo clones a Git repository into a Dagger Directory.

Parameters: - repoURL: The URL of the git repository to clone (e.g., “https://github.com/user/repo”). - token: (Optional) The VCS token to use for authentication. If not provided, the repository will be cloned without authentication. - vcs: (Optional) The version control system (VCS) to use for authentication. Defaults to “github”. Supported values are “github” and “gitlab”.

Returns: - *dagger.Directory: A directory object representing the cloned repository.

If a token is provided, it will be securely set using Dagger’s secret mechanism and used for authentication during the clone operation.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
repoUrlString !-repoURL is the URL of the git repo to clone.
tokenString -token is the VCS token to use for authentication. Optional parameter.
vcsString -vcs is the VCS to use for authentication. Optional parameter.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 clone-git-repo --repo-url string
func (m *myModule) example(repoUrl string) *Directory  {
	return dag.
			Gotoolbox().
			CloneGitRepo(repoUrl)
}
@function
def example(repo_url: str) -> dagger.Directory:
	return (
		dag.gotoolbox()
		.clone_git_repo(repo_url)
	)
@func()
example(repoUrl: string): Directory {
	return dag
		.gotoolbox()
		.cloneGitRepo(repoUrl)
}

withEnvironmentVariable() 🔗

WithEnvironmentVariable sets an environment variable in the container.

Parameters: - name: The name of the environment variable (e.g., “HOST”). - value: The value of the environment variable (e.g., “localhost”). - expand: Whether to replace ${VAR} or \(VAR in the value according to the current environment variables defined in the container (e.g., "/opt/bin:\)PATH”). Optional parameter.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
nameString !-name is the name of the environment variable.
valueString !-value is the value of the environment variable.
expandBoolean -expand is whether to replace `${VAR}` or $VAR in the value according to the current
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-environment-variable --name string --value string
func (m *myModule) example(name string, value string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithEnvironmentVariable(name, value)
}
@function
def example(name: str, value: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_environment_variable(name, value)
	)
@func()
example(name: string, value: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withEnvironmentVariable(name, value)
}

withSource() 🔗

WithSource sets the source directory for the container.

Parameters: - src: The directory that contains all the source code, including the module directory. - workdir: The working directory within the container. Optional parameter.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-src is the directory that contains all the source code, including the module directory.
workdirString -workdir is the working directory within the container. If not set it'll default to /mnt
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-source --src DIR_PATH
func (m *myModule) example(src *Directory) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithSource(src)
}
@function
def example(src: dagger.Directory) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_source(src)
	)
@func()
example(src: Directory): Gotoolbox {
	return dag
		.gotoolbox()
		.withSource(src)
}

withContainer() 🔗

WithContainer sets the container to be used.

Parameters: - ctr: The container to run the command in. If passed, it will override the container set in the Dagger instance.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
ctrContainer !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-container --ctr IMAGE:TAG
func (m *myModule) example(ctr *Container) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithContainer(ctr)
}
@function
def example(ctr: dagger.Container) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_container(ctr)
	)
@func()
example(ctr: Container): Gotoolbox {
	return dag
		.gotoolbox()
		.withContainer(ctr)
}

withSecretAsEnvVar() 🔗

WithSecretAsEnvVar sets an environment variable in the container using a secret.

Parameters: - name: The name of the environment variable (e.g., “API_KEY”). - secret: The secret containing the value of the environment variable.

Returns: - *Gotoolbox: The updated Gotoolbox with the environment variable set.

Behavior: - The secret value is expanded according to the current environment variables defined in the container.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
nameString !-No description provided
secretSecret !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-secret-as-env-var --name string --secret env:MYSECRET
func (m *myModule) example(name string, secret *Secret) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithSecretAsEnvVar(name, secret)
}
@function
def example(name: str, secret: dagger.Secret) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_secret_as_env_var(name, secret)
	)
@func()
example(name: string, secret: Secret): Gotoolbox {
	return dag
		.gotoolbox()
		.withSecretAsEnvVar(name, secret)
}

withDownloadedFile() 🔗

WithDownloadedFile downloads a file from the specified URL and mounts it in the container.

Parameters: - url: The URL of the file to download. - destDir: The directory within the container where the file will be downloaded. Optional parameter. If not provided, it defaults to the predefined mount prefix.

Returns: - *Gotoolbox: The updated Gotoolbox with the downloaded file mounted in the container.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
urlString !-url is the URL of the file to download.
destFileNameString -destFileName is the name of the file to download. If not set, it'll default to the basename of the URL.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-downloaded-file --url string
func (m *myModule) example(url string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithDownloadedFile(url)
}
@function
def example(url: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_downloaded_file(url)
	)
@func()
example(url: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withDownloadedFile(url)
}

withClonedGitRepo() 🔗

WithClonedGitRepo clones a Git repository and mounts it as a directory in the container.

This method downloads a Git repository and mounts it as a directory in the container. It supports optional authentication tokens for private repositories and can handle both GitHub and GitLab repositories.

Parameters: - repoURL: The URL of the git repository to clone (e.g., “https://github.com/user/repo”). - token: (Optional) The VCS token to use for authentication. If not provided, the repository will be cloned without authentication. - vcs: (Optional) The version control system (VCS) to use for authentication. Defaults to “github”. Supported values are “github” and “gitlab”.

Returns: - *Gotoolbox: The updated Gotoolbox with the cloned repository mounted in the container.

Return Type
Gotoolbox !
Arguments
NameTypeDefault ValueDescription
repoUrlString !-No description provided
tokenString -token is the VCS token to use for authentication. Optional parameter.
vcsString -vcs is the VCS to use for authentication. Optional parameter.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-cloned-git-repo --repo-url string
func (m *myModule) example(repoUrl string) *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithClonedGitRepo(repoUrl)
}
@function
def example(repo_url: str) -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_cloned_git_repo(repo_url)
	)
@func()
example(repoUrl: string): Gotoolbox {
	return dag
		.gotoolbox()
		.withClonedGitRepo(repoUrl)
}

withCacheBuster() 🔗

WithCacheBuster sets a cache-busting environment variable in the container.

This method sets an environment variable “CACHE_BUSTER” with a timestamp value in RFC3339Nano format. This can be useful for invalidating caches by providing a unique value.

Returns: - *Gotoolbox: The updated Gotoolbox with the cache-busting environment variable set.

Return Type
Gotoolbox !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 with-cache-buster
func (m *myModule) example() *Gotoolbox  {
	return dag.
			Gotoolbox().
			WithCacheBuster()
}
@function
def example() -> dag.Gotoolbox:
	return (
		dag.gotoolbox()
		.with_cache_buster()
	)
@func()
example(): Gotoolbox {
	return dag
		.gotoolbox()
		.withCacheBuster()
}

openTerminal() 🔗

OpenTerminal returns a terminal

It returns a terminal for the container. Arguments: - None. Returns: - *Terminal: The terminal for the container.

Return Type
Container !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 open-terminal
func (m *myModule) example() *Container  {
	return dag.
			Gotoolbox().
			OpenTerminal()
}
@function
def example() -> dagger.Container:
	return (
		dag.gotoolbox()
		.open_terminal()
	)
@func()
example(): Container {
	return dag
		.gotoolbox()
		.openTerminal()
}

runShell() 🔗

RunShell runs a shell command in the container.

It runs a shell command in the container and returns the output. Arguments: - cmd: The command to run in the container. Returns: - string: The output of the command. - error: An error if the command fails.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
cmdString !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 run-shell --cmd string
func (m *myModule) example(ctx context.Context, cmd string) string  {
	return dag.
			Gotoolbox().
			RunShell(ctx, cmd)
}
@function
async def example(cmd: str) -> str:
	return await (
		dag.gotoolbox()
		.run_shell(cmd)
	)
@func()
async example(cmd: string): Promise<string> {
	return dag
		.gotoolbox()
		.runShell(cmd)
}

printEnvVars() 🔗

PrintEnvVars retrieves and prints the environment variables of the container.

It executes the printenv command inside the container to get a list of all environment variables and their respective values.

Arguments: - None.

Returns: - string: A string containing all environment variables in the format “KEY=VALUE”, separated by newlines. - error: An error if the command fails, wrapped with additional context.

Usage example: “`go envVars, err := GotoolboxInstance.PrintEnvVars()

if err != nil {
    log.Fatalf("Error retrieving environment variables: %v", err)
}

fmt.Println(envVars).

Return Type
String !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 print-env-vars
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Gotoolbox().
			PrintEnvVars(ctx)
}
@function
async def example() -> str:
	return await (
		dag.gotoolbox()
		.print_env_vars()
	)
@func()
async example(): Promise<string> {
	return dag
		.gotoolbox()
		.printEnvVars()
}

inspectEnvVar() 🔗

InspectEnvVar inspects the value of an environment variable by its key Arguments: - key: The environment variable key to inspect. Returns: - string: The value of the environment variable. - error: An error if the key is invalid or the environment variable is not found.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
keyString !-No description provided
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 inspect-env-var --key string
func (m *myModule) example(ctx context.Context, key string) string  {
	return dag.
			Gotoolbox().
			InspectEnvVar(ctx, key)
}
@function
async def example(key: str) -> str:
	return await (
		dag.gotoolbox()
		.inspect_env_var(key)
	)
@func()
async example(key: string): Promise<string> {
	return dag
		.gotoolbox()
		.inspectEnvVar(key)
}

GoServer 🔗

GoServer represents a Go-based server configuration.

withServerData() 🔗

WithServerData configures the GoServer to use a cache volume at a specified path with specified sharing mode and ownership.

This method mounts a cache volume inside the container at the provided path, with specified sharing mode and ownership details. If any of these parameters are not provided, default values will be used.

Parameters:

path string: (optional) The path to the cache volume’s root. Defaults to “/data” if not provided. share dagger.CacheSharingMode: (optional) The sharing mode of the cache volume. Defaults to “shared” if not provided. owner string: (optional) The owner of the cache volume. Defaults to “1000:1000” if not provided.

Returns:

*GoServer: An instance of GoServer configured with the specified cache volume settings.

Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
pathString -path is the path to the cache volume's root. If not provided, it defaults to "/data".
shareEnum -share is the sharing mode of the cache volume. If not provided, it defaults to "shared".
ownerString -owner is the owner of the cache volume. If not provided, it defaults to "1000:1000".
workdirString -workdir is the working directory within the container. If not set it'll default to /mnt
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-server-data
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithServerData()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_server_data()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withServerData()
}

withBinaryName() 🔗

WithBinaryName sets the name of the binary to be built for the GoServer.

This method allows specifying a custom name for the binary to be built and used within the server container. If the binary name is not explicitly set, the default binary name (“app”) will be used.

Parameters:

binaryName string: The name of the binary to build.

Returns:

*GoServer: An instance of GoServer configured with the specified binary name.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
binaryNameString !-binaryName is the name of the binary to build.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-binary-name --binary-name string
func (m *myModule) example(binaryName string) *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithBinaryName(binaryName)
}
@function
def example(binary_name: str) -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_binary_name(binary_name)
	)
@func()
example(binaryName: string): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withBinaryName(binaryName)
}

withPreBuiltContainer() 🔗

WithPreBuiltContainer configures the GoServer to use a pre-existing container as its base.

This method allows setting an already created container as the base for the GoServer, overriding any previously set container.

Parameters:

ctr *dagger.Container: The container to use as a base container.

Returns:

*GoServer: An instance of GoServer configured with the provided container.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
ctrContainer !-ctr is the container to use as a base container.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-pre-built-container --ctr IMAGE:TAG
func (m *myModule) example(ctr *Container) *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithPreBuiltContainer(ctr)
}
@function
def example(ctr: dagger.Container) -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_pre_built_container(ctr)
	)
@func()
example(ctr: Container): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withPreBuiltContainer(ctr)
}

withExposePort() 🔗

WithExposePort sets the port to expose from the service.

This method allows setting the port to expose from the service.

Parameters:

port int: The port to expose from the service.

Returns:

*GoServer: An instance of GoServer configured with the provided port.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
portInteger !-ports is a list of ports to expose from the service.
skipHealthcheckBoolean -skipHealthcheck is a flag to skip the health check when run as a service.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-expose-port --port integer
func (m *myModule) example(port int) *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithExposePort(port)
}
@function
def example(port: int) -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_expose_port(port)
	)
@func()
example(port: number): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withExposePort(port)
}

withSource() 🔗

WithSource mounts the source directory inside the container and sets the working directory.

This method configures the GoServer to mount the provided source directory at a fixed mount point and optionally set a specific working directory within the container. If the working directory is not provided, it defaults to the mount point.

Parameters:

src *dagger.Directory: The directory containing all the source code, including the module directory.
workdir string: (optional) The working directory within the container, defaults to "/mnt".

Returns:

*GoServer: An instance of GoServer configured with the provided source directory and working directory.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-src is the directory that contains all the source code, including the module directory.
workdirString -workdir is the working directory within the container. If not set it'll default to /mnt
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-source --src DIR_PATH
func (m *myModule) example(src *Directory) *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithSource(src)
}
@function
def example(src: dagger.Directory) -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_source(src)
	)
@func()
example(src: Directory): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withSource(src)
}

withCompileOptions() 🔗

WithCompileOptions executes a user-defined compilation command within the container.

This method allows appending custom arguments to the “go build -o app” command for compiling the Go server. It always defaults to “go build -o app” but allows additional arguments such as verbose output, module mode, and build tags to customize the build process.

Parameters:

extraArgs []string: (optional) Extra arguments to append to the "go build -o app" command.
verbose bool: (optional) Flag to enable verbose output (adds the -v flag to the command).
mod string: (optional) Sets the module download mode (adds the -mod flag to the command).
tags string: (optional) A comma-separated list of build tags to consider
satisfied during the build (adds the -tags flag to the command).

Returns:

*GoServer: An instance of GoServer configured with the custom compilation command and any additional flags.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
extraArgs[String ! ] -extraArgs are additional arguments to append to the go build command.
verboseBoolean -verbose is a flag to enable verbose output.
modString -mod is the module download mode for the build.
tagsString -tags is a comma-separated list of build tags to consider satisfied during the build.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-compile-options
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithCompileOptions()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_compile_options()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withCompileOptions()
}

withRunOptions() 🔗

WithRunOptions adds extra arguments to the command when running the Go server binary.

This method allows additional arguments to be appended when running the server binary. Normally, the server is run as “./binary”, but if the binary that represents the Go server receives flags or additional arguments, these should be passed through this function.

Parameters:

runCmd []string: A list of additional command-line arguments to pass
when executing the server binary.

Returns:

*GoServer: An instance of GoServer configured to run the binary with the specified arguments.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
runFlags[String ! ] !-runCmd is a list of additional command-line arguments to pass when executing the server binary.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-run-options --run-flags string1 --run-flags string2
func (m *myModule) example(runFlags []string) *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithRunOptions(runFlags)
}
@function
def example(run_flags: List[str]) -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_run_options(run_flags)
	)
@func()
example(runFlags: string[]): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withRunOptions(runFlags)
}

withGoProxy() 🔗

WithGoProxy sets the Go Proxy URL for the service.

Parameters:

goproxy string: URL for the Go Proxy. If empty, defaults to "https://proxy.golang.org,direct".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
goproxyString -goproxy is the Go Proxy URL for the service.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-go-proxy
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithGoProxy()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_go_proxy()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withGoProxy()
}

withDnsresolver() 🔗

WithDNSResolver sets the DNS resolver for the service.

Parameters:

dnsResolver string: DNS resolver used by the service. If empty, defaults to "8.8.8.8 8.8.4.4".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
dnsResolverString -dnsResolver is the DNS resolver used by the service.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-dnsresolver
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithDnsresolver()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_dnsresolver()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withDnsresolver()
}

withGarbageCollectionSettings() 🔗

WithGarbageCollectionSettings sets the garbage collection optimization for the Go runtime.

Parameters:

gogc string: Garbage collection optimization value. If empty, defaults to "100".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
gogcString -gogc is the garbage collection optimization for the Go runtime.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-garbage-collection-settings
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithGarbageCollectionSettings()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_garbage_collection_settings()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withGarbageCollectionSettings()
}

withGoEnvironment() 🔗

WithGoEnvironment sets the Go environment for the service.

Parameters:

goEnv string: The Go environment. If empty, defaults to "production".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
goEnvString -goEnv is the Go environment.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-go-environment
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithGoEnvironment()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_go_environment()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withGoEnvironment()
}

withMaxProcs() 🔗

WithMaxProcs sets the maximum number of CPU cores to use.

Parameters:

goMaxProcs int: Maximum number of CPU cores to use. If 0, defaults to the number of available CPU cores.

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
goMaxProcsInteger -goMaxProcs is the maximum number of CPU cores to use.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-max-procs
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithMaxProcs()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_max_procs()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withMaxProcs()
}

withDebugOptions() 🔗

WithDebugOptions sets debug options for the Go runtime.

Parameters:

goDebug string: Debug options for Go. If empty, defaults to "http2debug=1".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
goDebugString -goDebug is the debug options for the Go runtime.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-debug-options
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithDebugOptions()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_debug_options()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withDebugOptions()
}

withRuntimeThreadLock() 🔗

WithRuntimeThreadLock optimizes the number of threads in system calls.

Parameters:

runtimeLockOsThread string: Optimizes number of threads in system calls. If empty, defaults to "1".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
runtimeLockOsThreadString -runtimeLockOsThread Optimizes number of threads in system calls.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-runtime-thread-lock
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithRuntimeThreadLock()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_runtime_thread_lock()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withRuntimeThreadLock()
}

withHttpsettings() 🔗

WithHTTPSettings sets HTTP-related settings for the service.

Parameters:

maxConns string: Maximum number of concurrent HTTP connections. If empty, defaults to "1000".
keepAlive string: Enables HTTP Keep-Alive. If empty, defaults to "1".

Returns:

*GoServer: The GoServer instance for method chaining.
Return Type
GoServer !
Arguments
NameTypeDefault ValueDescription
maxConnsString -maxConns is the maximum number of concurrent HTTP connections.
keepAliveString -keepAlive is the HTTP Keep-Alive setting.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 with-httpsettings
func (m *myModule) example() *GotoolboxGoServer  {
	return dag.
			Gotoolbox().
			NewGoServer().
			WithHttpsettings()
}
@function
def example() -> dag.GotoolboxGoServer:
	return (
		dag.gotoolbox()
		.new_go_server()
		.with_httpsettings()
	)
@func()
example(): GotoolboxGoServer {
	return dag
		.gotoolbox()
		.newGoServer()
		.withHttpsettings()
}

initService() 🔗

InitService sets up a basic Go service with the provided container and exposes the specified ports.

Returns:

*dagger.Service: The configured service with the specified ports exposed.
Return Type
Service !
Arguments
NameTypeDefault ValueDescription
ctrContainer -ctr is the container to use as a base container.
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 init-service
func (m *myModule) example() *Service  {
	return dag.
			Gotoolbox().
			NewGoServer().
			InitService()
}
@function
def example() -> dagger.Service:
	return (
		dag.gotoolbox()
		.new_go_server()
		.init_service()
	)
@func()
example(): Service {
	return dag
		.gotoolbox()
		.newGoServer()
		.initService()
}

initContainer() 🔗

InitContainer initializes the container with the default build and run commands.

This method sets up the container for the Go server. If custom compilation or run commands have not been provided, it defaults to building the server binary using “go build” and running the server binary directly.

Returns:

*dagger.Container: The initialized container with the default or custom commands.
Return Type
Container !
Example
dagger -m github.com/Excoriate/daggerverse/gotoolbox@a83a220c71aba509a487067926b196a0c9c0b83a call \
 new-go-server \
 init-container
func (m *myModule) example() *Container  {
	return dag.
			Gotoolbox().
			NewGoServer().
			InitContainer()
}
@function
def example() -> dagger.Container:
	return (
		dag.gotoolbox()
		.new_go_server()
		.init_container()
	)
@func()
example(): Container {
	return dag
		.gotoolbox()
		.newGoServer()
		.initContainer()
}