Process multiple consecutive goroutine snapshots.
()
| 129 | |
| 130 | // Process multiple consecutive goroutine snapshots. |
| 131 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…