MCPcopy
hub / github.com/tinygo-org/tinygo / Write

Method Write

main.go:2289–2315  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

2287type testStderr testOutputBuf
2288
2289func (out *testStderr) Write(data []byte) (int, error) {
2290 buf := (*testOutputBuf)(out)
2291 buf.mu.Lock()
2292
2293 if buf.stderr != nil {
2294 // Write the output directly.
2295 err := out.errerr
2296 buf.mu.Unlock()
2297 if err != nil {
2298 return 0, err
2299 }
2300 return buf.stderr.Write(data)
2301 }
2302
2303 defer buf.mu.Unlock()
2304
2305 // Append the output.
2306 if len(buf.output) == 0 || !buf.output[len(buf.output)-1].stderr {
2307 buf.output = append(buf.output, outputEntry{
2308 stderr: true,
2309 })
2310 }
2311 last := &buf.output[len(buf.output)-1]
2312 last.data = append(last.data, data...)
2313
2314 return len(data), nil
2315}
2316
2317type outputEntry struct {
2318 stderr bool

Callers

nothing calls this directly

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected