Checking whether a downloaded file matches a published checksum, or whether two
files differ without comparing them byte by byte, needs a digest of the file's
contents, and the version people write in a hurry reads the whole file into
memory first, which falls over on anything large. Streaming it through the hash
is five lines that are worth having written once and tested.
Definition of done: SHA256File(path string) (string, error) returns the
SHA-256 digest of the file's contents as lowercase hexadecimal, reading the file
in chunks rather than all at once, and returns the underlying error if the file
cannot be opened or read. It has a doc comment and table-driven tests covering
an empty file, a short file, a file larger than one read buffer, binary
contents, and a path that does not exist.
Model: opus-5
Checking whether a downloaded file matches a published checksum, or whether two
files differ without comparing them byte by byte, needs a digest of the file's
contents, and the version people write in a hurry reads the whole file into
memory first, which falls over on anything large. Streaming it through the hash
is five lines that are worth having written once and tested.
Definition of done: `SHA256File(path string) (string, error)` returns the
SHA-256 digest of the file's contents as lowercase hexadecimal, reading the file
in chunks rather than all at once, and returns the underlying error if the file
cannot be opened or read. It has a doc comment and table-driven tests covering
an empty file, a short file, a file larger than one read buffer, binary
contents, and a path that does not exist.
Model: opus-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Checking whether a downloaded file matches a published checksum, or whether two
files differ without comparing them byte by byte, needs a digest of the file's
contents, and the version people write in a hurry reads the whole file into
memory first, which falls over on anything large. Streaming it through the hash
is five lines that are worth having written once and tested.
Definition of done:
SHA256File(path string) (string, error)returns theSHA-256 digest of the file's contents as lowercase hexadecimal, reading the file
in chunks rather than all at once, and returns the underlying error if the file
cannot be opened or read. It has a doc comment and table-driven tests covering
an empty file, a short file, a file larger than one read buffer, binary
contents, and a path that does not exist.
Model: opus-5