simplify pc
diff --git a/errors.go b/errors.go
index 31ca468..8b9a230 100644
--- a/errors.go
+++ b/errors.go
@@ -28,12 +28,13 @@
// New returns an error that formats as the given text.
func New(text string) error {
+ pc, _, _, _ := runtime.Caller(1)
return struct {
error
loc
}{
fmt.Errorf(text),
- loc(pc()),
+ loc(pc),
}
}
@@ -57,10 +58,11 @@
if cause == nil {
return nil
}
+ pc, _, _, _ := runtime.Caller(1)
return &e{
cause: cause,
message: message,
- loc: loc(pc()),
+ loc: loc(pc),
}
}
@@ -132,8 +134,3 @@
err = cause.Cause()
}
}
-
-func pc() uintptr {
- pc, _, _, _ := runtime.Caller(2)
- return pc
-}