MCPcopy Create free account
hub / github.com/quay/clair / JSONReader

Function JSONReader

internal/codec/reader.go:7–20  ·  view source on GitHub ↗

JSONReader returns an io.ReadCloser backed by a pipe being fed by a JSON encoder.

(v interface{})

Source from the content-addressed store, hash-verified

5// JSONReader returns an io.ReadCloser backed by a pipe being fed by a JSON
6// encoder.
7func JSONReader(v interface{}) io.ReadCloser {
8 r, w := io.Pipe()
9 // This unsupervised goroutine should be fine, because the writer will error
10 // once the reader is closed.
11 go func() {
12 enc := GetEncoder(w)
13 defer PutEncoder(enc)
14 defer w.Close()
15 if err := enc.Encode(v); err != nil {
16 w.CloseWithError(err)
17 }
18 }()
19 return r
20}

Callers 8

ScanMethod · 0.92
AffectedManifestsMethod · 0.92
IndexMethod · 0.92
DeleteManifestsMethod · 0.92
IndexReportMethod · 0.92
DeleteIndexReportsMethod · 0.92
DeliverMethod · 0.92
BenchmarkDecodeFunction · 0.85

Calls 3

GetEncoderFunction · 0.85
PutEncoderFunction · 0.85
CloseMethod · 0.65

Tested by 1

BenchmarkDecodeFunction · 0.68