MCPcopy Create free account
hub / github.com/go-task/task / SyncBuffer

Struct SyncBuffer

task_test.go:383–386  ·  view source on GitHub ↗

SyncBuffer is a threadsafe buffer for testing. Some times replace stdout/stderr with a buffer to capture output. stdout and stderr are threadsafe, but a regular bytes.Buffer is not. Using this instead helps prevents race conditions with output.

Source from the content-addressed store, hash-verified

381// stdout and stderr are threadsafe, but a regular bytes.Buffer is not.
382// Using this instead helps prevents race conditions with output.
383type SyncBuffer struct {
384 buf bytes.Buffer
385 mu sync.Mutex
386}
387
388func (sb *SyncBuffer) Write(p []byte) (n int, err error) {
389 sb.mu.Lock()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected