keepWriteErr remembers err as the error to return from [Program.Run] if it is the first error writing to the output. Later errors are dropped so they do not hide the first one.
(err error)
| 1402 | // is the first error writing to the output. Later errors are dropped so they |
| 1403 | // do not hide the first one. |
| 1404 | func (p *Program) keepWriteErr(err error) { |
| 1405 | if err == nil { |
| 1406 | return |
| 1407 | } |
| 1408 | p.writeErrMu.Lock() |
| 1409 | defer p.writeErrMu.Unlock() |
| 1410 | if p.writeErr == nil { |
| 1411 | p.writeErr = err |
| 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | // firstWriteErr returns the first error kept by keepWriteErr. |
| 1416 | func (p *Program) firstWriteErr() error { |
no outgoing calls