https://github.com/go-stack/stack
Package stack implements utilities to capture, manipulate, and format call stacks.
https://github.com/go-stack/stack
go golang stacktrace
Last synced: about 2 months ago
JSON representation
Package stack implements utilities to capture, manipulate, and format call stacks.
- Host: GitHub
- URL: https://github.com/go-stack/stack
- Owner: go-stack
- License: mit
- Created: 2014-10-30T02:31:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T18:48:25.000Z (over 3 years ago)
- Last Synced: 2025-03-10T01:56:46.111Z (about 2 months ago)
- Topics: go, golang, stacktrace
- Language: Go
- Homepage:
- Size: 1.12 MB
- Stars: 397
- Watchers: 6
- Forks: 35
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- go-awesome - stack - Capture, edit and format call stack information (Open source library / Debugging)
README
[](https://godoc.org/github.com/go-stack/stack)
[](https://goreportcard.com/report/go-stack/stack)
[](https://travis-ci.org/go-stack/stack)
[](https://coveralls.io/github/go-stack/stack?branch=master)# stack
Package stack implements utilities to capture, manipulate, and format call
stacks. It provides a simpler API than package runtime.The implementation takes care of the minutia and special cases of interpreting
the program counter (pc) values returned by runtime.Callers.## Versioning
Package stack publishes releases via [semver](http://semver.org/) compatible Git
tags prefixed with a single 'v'. The master branch always contains the latest
release. The develop branch contains unreleased commits.## Formatting
Package stack's types implement fmt.Formatter, which provides a simple and
flexible way to declaratively configure formatting when used with logging or
error tracking packages.```go
func DoTheThing() {
c := stack.Caller(0)
log.Print(c) // "source.go:10"
log.Printf("%+v", c) // "pkg/path/source.go:10"
log.Printf("%n", c) // "DoTheThing"s := stack.Trace().TrimRuntime()
log.Print(s) // "[source.go:15 caller.go:42 main.go:14]"
}
```See the docs for all of the supported formatting options.