diff --git a/errorlint/allowed.go b/errorlint/allowed.go index cf48170..04eeddb 100644 --- a/errorlint/allowed.go +++ b/errorlint/allowed.go @@ -84,6 +84,7 @@ func setDefaultAllowedErrors() { {Err: "context.Canceled", Fun: "(context.Context).Err"}, // pkg/encoding/json {Err: "io.EOF", Fun: "(*encoding/json.Decoder).Decode"}, + {Err: "io.EOF", Fun: "(*encoding/json.Decoder).Token"}, // pkg/encoding/csv {Err: "io.EOF", Fun: "(*encoding/csv.Reader).Read"}, // pkg/mime/multipart diff --git a/errorlint/testdata/src/allowed/allowed.go b/errorlint/testdata/src/allowed/allowed.go index e3ff1ce..acac223 100644 --- a/errorlint/testdata/src/allowed/allowed.go +++ b/errorlint/testdata/src/allowed/allowed.go @@ -251,11 +251,16 @@ func ContextErr(ctx context.Context) error { return nil } -func JSONReader(r io.Reader) { - err := json.NewDecoder(r).Decode(nil) +func JSONReader(dec *json.Decoder) (err error) { + _, err = dec.Token() if err == io.EOF { - fmt.Println(err) + return + } + err = dec.Decode(nil) + if err == io.EOF { + return } + return } func CSVReader(r io.Reader) {