This repository was archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_test.go
More file actions
53 lines (37 loc) · 1.33 KB
/
stack_test.go
File metadata and controls
53 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package erf_test
import (
"fmt"
"github.com/goinsane/erf"
)
func ExampleStackCaller() {
e := erf.New("an example erf error")
sc := e.StackTrace().Caller(0)
fmt.Println("just show function and entry without padding and indent.")
fmt.Printf("%s\n\n", sc)
fmt.Println("show file path, line and pc. padding char '\\t', default padding 0, default indent 1.")
fmt.Printf("%+s\n\n", sc)
fmt.Println("use file name as file path.")
fmt.Printf("%#s\n\n", sc)
fmt.Println("padding 2, indent 1 by default.")
fmt.Printf("%#2s\n\n", sc)
fmt.Println("padding 2, indent 3.")
fmt.Printf("%#2.3s\n\n", sc)
fmt.Println("show file path, line and pc. padding char ' ', default padding 0, default indent 2.")
fmt.Printf("% s\n\n", sc)
fmt.Println("use file name as file path.")
fmt.Printf("% #s\n\n", sc)
fmt.Println("padding 2, indent 2 by default.")
fmt.Printf("% #2s\n\n", sc)
fmt.Println("padding 2, indent 3.")
fmt.Printf("% #2.3s\n\n", sc)
}
func ExampleStackTrace() {
e := erf.New("an example erf error")
st := e.StackTrace()
fmt.Println("default")
fmt.Printf("%s\n\n", st)
fmt.Println("show file path, line and pc. padding char '\\t', default padding 0, default indent 1.")
fmt.Printf("%+s\n\n", st)
fmt.Println("show file path, line and pc. padding char ' ', default padding 0, default indent 2.")
fmt.Printf("% s\n\n", st)
}