File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change
1
+ package stack_test
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/go-stack/stack"
7
+ )
8
+
9
+ func Example_callFormat () {
10
+ log ("%+s" )
11
+ log ("%v %[1]n()" )
12
+ // Output:
13
+ // github.com/go-stack/stack/format_test.go
14
+ // format_test.go:11 Example_callFormat()
15
+ }
16
+
17
+ func log (format string ) {
18
+ fmt .Printf (format + "\n " , stack .Caller (1 ))
19
+ }
Original file line number Diff line number Diff line change 1
1
// Package stack implements utilities to capture, manipulate, and format call
2
- // stacks.
2
+ // stacks. It provides a simpler API than package runtime.
3
+ //
4
+ // The implementation takes care of the minutia and special cases of
5
+ // interpreting the program counter (pc) values returned by runtime.Callers.
6
+ //
7
+ // Package stack's types implement fmt.Formatter, which provides a simple and
8
+ // flexible way to declaratively configure formatting when used with logging
9
+ // or error tracking packages.
3
10
package stack
4
11
5
12
import (
@@ -234,7 +241,7 @@ func Trace() CallStack {
234
241
return cs
235
242
}
236
243
237
- // TrimBelow returns a slice of the CallStack with all entries below pc
244
+ // TrimBelow returns a slice of the CallStack with all entries below c
238
245
// removed.
239
246
func (cs CallStack ) TrimBelow (c Call ) CallStack {
240
247
for len (cs ) > 0 && cs [0 ].pc != c .pc {
@@ -243,7 +250,7 @@ func (cs CallStack) TrimBelow(c Call) CallStack {
243
250
return cs
244
251
}
245
252
246
- // TrimAbove returns a slice of the CallStack with all entries above pc
253
+ // TrimAbove returns a slice of the CallStack with all entries above c
247
254
// removed.
248
255
func (cs CallStack ) TrimAbove (c Call ) CallStack {
249
256
for len (cs ) > 0 && cs [len (cs )- 1 ].pc != c .pc {
You can’t perform that action at this time.
0 commit comments