mirror of
https://github.com/restic/restic.git
synced 2025-11-16 03:13:40 +00:00
errcheck: Add error checks
Most added checks are straight forward.
This commit is contained in:
@@ -21,8 +21,16 @@ func NewWriter(w io.Writer, h hash.Hash) *Writer {
|
||||
|
||||
// Write wraps the write method of the underlying writer and also hashes all data.
|
||||
func (h *Writer) Write(p []byte) (int, error) {
|
||||
// write the data to the underlying writing
|
||||
n, err := h.w.Write(p)
|
||||
h.h.Write(p[:n])
|
||||
|
||||
// according to the interface documentation, Write() on a hash.Hash never
|
||||
// returns an error.
|
||||
_, hashErr := h.h.Write(p[:n])
|
||||
if hashErr != nil {
|
||||
panic(hashErr)
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user