Created
April 24, 2019 03:58
-
-
Save farhany/1aa95e1c342ab8722bd2adb7afbcf591 to your computer and use it in GitHub Desktop.
Basic use of TeeReader to reduce memory consumption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://stackoverflow.com/questions/41947307/how-to-return-hash-and-bytes-in-one-step-in-go | |
hasher := sha256.New() | |
f, err := os.Open(fname) | |
data := io.TeeReader(f, hasher) | |
// Now read from data as usual, which is still a stream. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment