A sample parseStack function expects a stdlib stacktrace from runtime.Stack or debug.Stack and returns the parsed stack object.
()
| 166 | // A sample parseStack function expects a stdlib stacktrace from runtime.Stack or debug.Stack and returns |
| 167 | // the parsed stack object. |
| 168 | func Example_simple() { |
| 169 | parseStack := func(rawStack []byte) stack.Stack { |
| 170 | s, _, err := stack.ScanSnapshot(bytes.NewReader(rawStack), io.Discard, stack.DefaultOpts()) |
| 171 | if err != nil && err != io.EOF { |
| 172 | panic(err) |
| 173 | } |
| 174 | |
| 175 | if len(s.Goroutines) > 1 { |
| 176 | panic(errors.New("provided stacktrace had more than one goroutine")) |
| 177 | } |
| 178 | |
| 179 | return s.Goroutines[0].Signature.Stack |
| 180 | } |
| 181 | |
| 182 | parsedStack := parseStack(debug.Stack()) |
| 183 | fmt.Printf("parsedStack: %#v", parsedStack) |
| 184 | } |
| 185 | |
| 186 | // Registers a middleware to trap exceptions and report them on http.Handler. |
| 187 | // |
nothing calls this directly
no test coverage detected
searching dependent graphs…