Skip to content

Commit f823376

Browse files
committed
Improve README.
1 parent eb70383 commit f823376

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@
22
?status.svg)](https://godoc.org/github.com/go-stack/stack
33
) [![Build Status](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack)
44

5+
# stack
6+
57
Package stack implements utilities to capture, manipulate, and format call stacks. It provides a simpler API than package runtime.
68

79
The implementation takes care of the minutia and special cases of interpreting the program counter (pc) values returned by runtime.Callers.
810

11+
## Versioning
12+
Package stack publishes stable APIs via gopkg.in. The most recent is v0 (the API is still baking, please file an issue if you have any suggestions), which is imported like so:
13+
14+
import "gopkg.in/stack.v0"
15+
16+
## Formatting
917
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.
18+
19+
```go
20+
func DoTheThing() {
21+
c := stack.Caller(0)
22+
log.Print(c) // might log "source.go:10"
23+
log.Printf("%+v", c) // might log "pkg/path/source.go:10"
24+
log.Printf("%n", c) // might log "DoTheThing"
25+
26+
s := stack.Trace()
27+
log.Print(s) // might log "[source.go:15 caller.go:42 main.go:14]"
28+
}
29+
```
30+
31+
See the docs for all of the supported formatting options.

0 commit comments

Comments
 (0)