The Sprites Go SDK exposes aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/superfly/sprites-go/llms.txt
Use this file to discover all available pages before exploring further.
Cmd type that mirrors the standard library’s exec.Cmd, so running a command on a remote Sprite feels exactly like running one locally. You create a Cmd from a Sprite handle, configure any fields you need, then call one of the execution methods.
Creating a command
Usesprite.Command to create a Cmd for a given program and its arguments. The first argument is the program name; any additional arguments are passed through as-is.
With context
Usesprite.CommandContext when you need cancellation or a timeout. The SDK kills the remote process if the context is cancelled before the command finishes.
Passing a
nil context to CommandContext panics. Always pass a valid context, such as context.Background().Execution methods
cmd.Run()
Run starts the command and blocks until it exits. It is the simplest way to execute a command when you don’t need to capture output.
cmd.Output()
Output runs the command and returns its standard output as a byte slice. Standard error is discarded unless you set cmd.Stderr explicitly.
cmd.CombinedOutput()
CombinedOutput runs the command and returns stdout and stderr merged into a single byte slice, in the order the remote process writes them.
cmd.Start() and cmd.Wait()
Use Start and Wait separately when you need to interact with the process while it runs — for example, to write to stdin, read from a pipe, or send a signal mid-flight.
Configuring the environment
Environment variables
Setcmd.Env to a slice of "key=value" strings. If Env is nil, the remote process inherits the Sprite’s default environment.
Working directory
Setcmd.Dir to run the process in a specific directory on the Sprite. An empty string uses the Sprite’s default directory.
Signals
AfterStart, you can send a POSIX signal to the remote process with cmd.Signal. The SDK uses the existing WebSocket connection when the server supports it, and falls back to an HTTP request otherwise.
Valid signal names: INT, TERM, HUP, KILL, QUIT, USR1, USR2.
Exit codes
cmd.ExitCode() returns the numeric exit code once the process has finished, or -1 if it is still running or was terminated abnormally.
Connection mode
cmd.ConnectionMode() reports how the SDK connected for this command. It returns "control" when the SDK multiplexed over a shared control WebSocket, "direct" when it opened a dedicated WebSocket, or an empty string before Start is called.
Context cancellation
When the context passed toCommandContext is cancelled or times out, the SDK kills the remote process. Combine this with Start/Wait for fine-grained control.