Skip to content

Commit fb99cb5

Browse files
committed
add panic testcase
1 parent 550d46c commit fb99cb5

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

test/testdata/zerologlint/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ require (
66
github.com/mattn/go-colorable v0.1.12 // indirect
77
github.com/mattn/go-isatty v0.0.14 // indirect
88
github.com/rs/zerolog v1.29.0 // indirect
9-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
9+
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
10+
golang.org/x/sys v0.1.0 // indirect
1011
)

test/testdata/zerologlint/go.sum

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testdata/zerologlint/zerologlint.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66

77
"github.com/rs/zerolog"
88
"github.com/rs/zerolog/log"
9+
"golang.org/x/exp/slices"
910
)
1011

11-
func bad() {
12+
func expectWarnings() {
1213
log.Error() // want "must be dispatched by Msg or Send method"
1314
log.Info() // want "must be dispatched by Msg or Send method"
1415
log.Fatal() // want "must be dispatched by Msg or Send method"
@@ -38,7 +39,7 @@ func bad() {
3839
logger2.Str("foo", "bar")
3940
}
4041

41-
func ok() {
42+
func expectNoWarnings() {
4243
log.Fatal().Send()
4344
log.Panic().Msg("")
4445
log.Debug().Send()
@@ -68,3 +69,9 @@ func ok() {
6869
}
6970
logger2.Send()
7071
}
72+
73+
// https://github.com/ykadowak/zerologlint/pull/2
74+
func packageNil() {
75+
s := []int{1, 2, 3}
76+
slices.Sort(s)
77+
}

0 commit comments

Comments
 (0)