-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove the stack library dependency (#10)
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
- Loading branch information
1 parent
ad0641e
commit 1befbfc
Showing
4 changed files
with
43 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= | ||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= | ||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= | ||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package stack | ||
|
||
import "runtime" | ||
|
||
// Caller returns a frame from the stack of the current goroutine. The argument | ||
// skip is the number of frames to ascend, with 0 identifying the | ||
// calling function. | ||
func Caller(skip int) runtime.Frame { | ||
var pcs [3]uintptr | ||
|
||
n := runtime.Callers(skip+1, pcs[:]) | ||
frames := runtime.CallersFrames(pcs[:n]) | ||
frame, _ := frames.Next() | ||
frame, _ = frames.Next() | ||
|
||
return frame | ||
} | ||
|
||
// Trace returns a call stack for the current goroutine with element 0 | ||
// identifying the calling function. | ||
func Trace() []runtime.Frame { | ||
var pcs [512]uintptr | ||
n := runtime.Callers(1, pcs[:]) | ||
|
||
frames := runtime.CallersFrames(pcs[:n]) | ||
cs := make([]runtime.Frame, 0, n) | ||
|
||
// Skip extra frame retrieved just to make sure the runtime.sigpanic | ||
// special case is handled. | ||
frame, more := frames.Next() | ||
|
||
for more { | ||
frame, more = frames.Next() | ||
cs = append(cs, frame) | ||
} | ||
|
||
return cs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters