Last active
April 25, 2021 16:58
-
-
Save Ramko9999/e5895bc4789915ff681dcff0c3818eec to your computer and use it in GitHub Desktop.
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
| func readFileChunkWise() { | |
| chunkSize := 10 // processing the file 10 bytes at a time | |
| b := make([]byte, chunkSize) | |
| file, err := os.Open("./folder/test.txt); | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| for { | |
| bytesRead, _ := file.Read(b); | |
| if bytesRead == 0 { // bytesRead will be 0 at the end of the file. | |
| break | |
| } | |
| // process the current bytes read | |
| process(b, bytesRead); | |
| } | |
| file.Close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment