| 42 | } |
| 43 | |
| 44 | func newPanicError(v interface{}) error { |
| 45 | stack := debug.Stack() |
| 46 | |
| 47 | // The first line of the stack trace is of the form "goroutine N [status]:" |
| 48 | // but by the time the panic reaches Do the goroutine may no longer exist |
| 49 | // and its status will have changed. Trim out the misleading line. |
| 50 | if line := bytes.IndexByte(stack, '\n'); line >= 0 { |
| 51 | stack = stack[line+1:] |
| 52 | } |
| 53 | return &panicError{value: v, stack: stack} |
| 54 | } |
| 55 | |
| 56 | // call is an in-flight or completed singleflight.Do call |
| 57 | type call[V any] struct { |