Last active
August 14, 2019 13:04
-
-
Save awnumar/b7f63553ad0619c783a94daddcc4bb53 to your computer and use it in GitHub Desktop.
Read data (1024) bytes at a time
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
data := "xxx[...]xxx" | |
var chunk []byte | |
for i := 0; i < len(data); i += 1024 { | |
if i+1024 > len(data) { | |
// Remaining data <= 1024. | |
chunk = data[len(data)-(len(data)%1024):] | |
} else { | |
// Split into chunks of 1024 bytes and pad. | |
chunk = data[i:i+1024] | |
} | |
// Handle chunk. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment