@@ -26,6 +26,8 @@ type StackInfo struct {
26
26
27
27
// these are used to filter out specific lines from output
28
28
ExlRegexp []* regexp.Regexp
29
+
30
+ PrintFirstOnly bool
29
31
}
30
32
31
33
var (
@@ -39,14 +41,19 @@ var (
39
41
40
42
// we want to check that this is not our package
41
43
packageRegexp = regexp .MustCompile (
42
- `^github\.com/lainio/err2[a-zA-Z0-9_/.\[\]]*\(` ,
44
+ `^github\.com/lainio/err2[a-zA-Z0-9_/\ .\[\]\@ ]*\(` ,
43
45
)
44
46
45
47
// testing package exluding regexps:
46
48
testingPkgRegexp = regexp .MustCompile (`^testing\.` )
47
49
testingFileRegexp = regexp .MustCompile (`^.*\/src\/testing\/testing\.go` )
48
50
49
- exludeRegexps = []* regexp.Regexp {testingPkgRegexp , testingFileRegexp }
51
+ exludeRegexps = []* regexp.Regexp {testingPkgRegexp , testingFileRegexp }
52
+ exludeRegexpsAll = []* regexp.Regexp {
53
+ testingPkgRegexp ,
54
+ testingFileRegexp ,
55
+ packageRegexp ,
56
+ }
50
57
)
51
58
52
59
func (si StackInfo ) fullName () string {
@@ -89,7 +96,11 @@ func (si StackInfo) canPrint(s string, anchorLine, i int) (ok bool) {
89
96
// printed from call stack.
90
97
anchorLine = 0
91
98
}
92
- ok = i >= 2 * si .Level + anchorLine
99
+ if si .PrintFirstOnly {
100
+ ok = i >= 2 * si .Level + anchorLine && i < 2 * si .Level + anchorLine + 2
101
+ } else {
102
+ ok = i >= 2 * si .Level + anchorLine
103
+ }
93
104
94
105
if si .ExlRegexp == nil {
95
106
return ok
@@ -271,7 +282,7 @@ func stackPrint(r io.Reader, w io.Writer, si StackInfo) {
271
282
line := scanner .Text ()
272
283
273
284
// we can print a line if we didn't find anything, i.e. anchorLine is
274
- // nilAnchor, which means that our start is not limited by then anchor
285
+ // nilAnchor, which means that our start is not limited by the anchor
275
286
canPrint := anchorLine == nilAnchor
276
287
// if it's not nilAnchor we need to check it more carefully
277
288
if ! canPrint {
0 commit comments