While playing around with the new vet and its nilness check, I have found an interesting bug. In src/archive/zip/reader_test.go:985 we have a test for #10956, but the test doesn't actually check anything:
_, err := NewReader(bytes.NewReader(data), int64(len(data)))
// …
if err == nil && !strings.Contains(err.Error(), want) {
t.Errorf("error = %v; want %q", err, want)
}
It should obviously be if err != nil && … here. But when I changed it, the test failed, because it returned ErrFormat instead of the custom Errorf'd error that was expected. I ran all of the package zip's tests with -cover and the coverage profile shows that the branch in (*Reader).init is never taken.
While playing around with the new vet and its nilness check, I have found an interesting bug. In
src/archive/zip/reader_test.go:985we have a test for #10956, but the test doesn't actually check anything:It should obviously be
if err != nil && …here. But when I changed it, the test failed, because it returnedErrFormatinstead of the custom Errorf'd error that was expected. I ran all of the package zip's tests with -cover and the coverage profile shows that the branch in(*Reader).initis never taken.