The Sprites Go SDK handles standard I/O the same way the standard library’sDocumentation 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.
exec.Cmd does: you can attach any io.Reader as stdin and any io.Writer as stdout or stderr, or ask for pipe ends that you read and write yourself. All data is transported over the WebSocket connection transparently.
Attaching readers and writers directly
Setcmd.Stdin, cmd.Stdout, and cmd.Stderr before calling Start or any single-step method (Run, Output, CombinedOutput).
If
Stdin is nil, the remote process reads from /dev/null. If Stdout or Stderr is nil, the corresponding stream is discarded.Using pipes
Pipes give you anio.WriteCloser for stdin and io.ReadCloser values for stdout and stderr that you can use from your own goroutines. All three pipe methods must be called before Start.
cmd.StdinPipe()
StdinPipe returns a write end you control. Close it when you have finished writing so the remote process sees EOF.
cmd.StdoutPipe()
StdoutPipe returns a read end connected to the process’s stdout stream.
cmd.StderrPipe()
StderrPipe returns a read end connected to the process’s stderr stream.
Full pipe example
The example below streams ten lines to acat process while reading the output line-by-line with a bufio.Scanner.
Concurrent I/O patterns
When you need to read stdout and stderr simultaneously, start a goroutine for each pipe so neither blocks the other.Scanner pattern for line-by-line reading
Abufio.Scanner wrapping a StdoutPipe is the idiomatic way to process output one line at a time without buffering the entire output in memory.
Receiving port notifications
cmd.TextMessageHandler is called for out-of-band text messages that arrive alongside the binary I/O stream. The most common use is reacting to port lifecycle events when the remote process opens or closes a listening port.
TextMessageHandler is called from the WebSocket read loop. Keep the handler fast and non-blocking, or hand off work to a channel or goroutine to avoid stalling I/O delivery.Choosing the right I/O approach
When to use cmd.Stdin / cmd.Stdout / cmd.Stderr
When to use cmd.Stdin / cmd.Stdout / cmd.Stderr
Assign readers and writers directly when the full input is already available as an
io.Reader (for example, strings.NewReader or bytes.NewReader), or when you want to direct output into a buffer or file. This is the simplest approach and requires no goroutine coordination.When to use pipes
When to use pipes
Use pipes when you need to produce stdin data or consume stdout/stderr data concurrently with the command running. Pipes are also the right choice when you want to process output incrementally rather than waiting for the process to exit.
When to use CombinedOutput
When to use CombinedOutput
Use
CombinedOutput when you only care whether the command succeeded and want a single log-friendly byte slice of everything the process printed, regardless of which stream it used.