MCPcopy Index your code
hub / github.com/maruel/panicparse / Example_stream

Function Example_stream

stack/example_test.go:131–152  ·  view source on GitHub ↗

Process multiple consecutive goroutine snapshots.

()

Source from the content-addressed store, hash-verified

129
130// Process multiple consecutive goroutine snapshots.
131func Example_stream() {
132 // Stream of stack traces:
133 var r io.Reader
134 var w io.Writer
135 opts := stack.DefaultOpts()
136 for {
137 s, suffix, err := stack.ScanSnapshot(r, w, opts)
138 if s != nil {
139 // Process the snapshot...
140 }
141
142 if err != nil && err != io.EOF {
143 if len(suffix) != 0 {
144 w.Write(suffix)
145 }
146 log.Fatal(err)
147 }
148 // Prepend the suffix that was read to the rest of the input stream to
149 // catch the next snapshot signature:
150 r = io.MultiReader(bytes.NewReader(suffix), r)
151 }
152}
153
154// Converts a stack trace from os.Stdin into HTML on os.Stdout, discarding
155// everything else.

Callers

nothing calls this directly

Calls 3

DefaultOptsFunction · 0.92
ScanSnapshotFunction · 0.92
WriteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…