MCPcopy Index your code
hub / github.com/coder/coder / DiscardAfterClose

Function DiscardAfterClose

cli/cliutil/sink.go:17–19  ·  view source on GitHub ↗

DiscardAfterClose is an io.WriteCloser that discards writes after it is closed without errors. It is useful as a target for a slog.Sink such that an underlying WriteCloser, like a file, can be cleaned up without race conditions from still-active loggers.

(wc io.WriteCloser)

Source from the content-addressed store, hash-verified

15// It is useful as a target for a slog.Sink such that an underlying WriteCloser, like a file, can
16// be cleaned up without race conditions from still-active loggers.
17func DiscardAfterClose(wc io.WriteCloser) io.WriteCloser {
18 return &discardAfterClose{wc: wc}
19}
20
21func (d *discardAfterClose) Write(p []byte) (n int, err error) {
22 d.Lock()

Callers 3

sshMethod · 0.92
vscodeSSHMethod · 0.92
TestDiscardAfterCloseFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestDiscardAfterCloseFunction · 0.74