4 ms·
Also a good example of programmer masochism, there's absolutely no good reason for zd, err := gzip.NewReader(fd) to return an error rather than waiting fo
by morelisp 3y ago
Also a good example of programmer masochism, there's absolutely no good reason for
zd, err := gzip.NewReader(fd)
to return an error rather than waiting for an actual read. The stdlib is usually pretty good about this but third-party libraries are rife with this kind of misdesign.
- imran-iq 3y agoYou should try reading the source code and you will get your answer. NewReader[0] calls Reset[1], which calls readHeader[2], which the name should tell you what its doing. --- 0: https://github.com/golang/go/blob/go1.21.3/src/compress/gzip/gunzip.go#L94 https://github.com/golang/go/blob/go1.21.3/src/compress/gzip... 1: https://github.com/golang/go/blob/go1.21.3/src/compress/gzip/gunzip.go#L113 https://github.com/golang/go/blob/go1.21.3/src/compress/gzip... 2: https://github.com/golang/go/blob/go1.21.3/src/compress/gzip/gunzip.go#L174 https://github.com/golang/go/blob/go1.21.3/src/compress/gzip...
- morelisp 3y ago"My answer"? I didn't ask a question! I know what the code does, that doesn't make it less bad design.