pkg / errors

Simple error handling primitives
https://godoc.org/github.com/pkg/errors
BSD 2-Clause "Simplified" License
8.18k stars 691 forks source link

return *stack instead of stack #237

Open simon28082 opened 3 years ago

simon28082 commented 3 years ago

Hi, I see that the callers in the source code return *stack instead of stack. Why does this happen?

func callers() *stack {
    const depth = 32
    var pcs [depth]uintptr
    n := runtime.Callers(3, pcs[:])
    var st stack = pcs[0:n]
    return &st
}
davecheney commented 3 years ago

Honestly don’t remember. I can’t think of a reason why it was don’t that way.

mitar commented 2 years ago

I think because fundamental uses *stack. So it is easier to write stack: callers(). So the question is, why fundamental uses *stack. :-)