• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.travis.ymlH A D26-Aug-2018186

LICENSE.mdH A D26-Aug-20181.1 KiB

README.mdH A D26-Aug-20181.5 KiB

format_test.goH A D26-Aug-2018340

go.modH A D26-Aug-201833

stack-go19_test.goH A D26-Aug-20181.5 KiB

stack.goH A D26-Aug-201811.6 KiB

stack_test.goH A D26-Aug-201812.5 KiB

README.md

1[![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack)
2[![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack)
3[![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack)
4[![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master)
5
6# stack
7
8Package stack implements utilities to capture, manipulate, and format call
9stacks. It provides a simpler API than package runtime.
10
11The implementation takes care of the minutia and special cases of interpreting
12the program counter (pc) values returned by runtime.Callers.
13
14## Versioning
15
16Package stack publishes releases via [semver](http://semver.org/) compatible Git
17tags prefixed with a single 'v'. The master branch always contains the latest
18release. The develop branch contains unreleased commits.
19
20## Formatting
21
22Package stack's types implement fmt.Formatter, which provides a simple and
23flexible way to declaratively configure formatting when used with logging or
24error tracking packages.
25
26```go
27func DoTheThing() {
28    c := stack.Caller(0)
29    log.Print(c)          // "source.go:10"
30    log.Printf("%+v", c)  // "pkg/path/source.go:10"
31    log.Printf("%n", c)   // "DoTheThing"
32
33    s := stack.Trace().TrimRuntime()
34    log.Print(s)          // "[source.go:15 caller.go:42 main.go:14]"
35}
36```
37
38See the docs for all of the supported formatting options.
39