Skip to content

Commit

Permalink
Make code shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Sep 19, 2023
1 parent b813d79 commit 954ff60
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions activation/nipost_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ func write(path string, data []byte) error {
if err != nil {
return fmt.Errorf("create temporary file %s: %w", tmpName, err)
}
defer tmp.Close()

checksum := crc64.New(crc64.MakeTable(crc64.ISO))
w := io.MultiWriter(tmp, checksum)
if _, err := w.Write(data); err != nil {
err = errors.Join(err, tmp.Close())
return fmt.Errorf("write data %v: %w", tmp.Name(), err)
}

crc := make([]byte, crc64.Size)
binary.BigEndian.PutUint64(crc, checksum.Sum64())
if _, err := tmp.Write(crc); err != nil {
err = errors.Join(err, tmp.Close())
return fmt.Errorf("write checksum %s: %w", tmp.Name(), err)
}

Expand Down

0 comments on commit 954ff60

Please sign in to comment.