Skip to content

Instantly share code, notes, and snippets.

@awnumar
Last active August 14, 2019 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awnumar/b7f63553ad0619c783a94daddcc4bb53 to your computer and use it in GitHub Desktop.
Save awnumar/b7f63553ad0619c783a94daddcc4bb53 to your computer and use it in GitHub Desktop.
Read data (1024) bytes at a time
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