Golang io.ReadAtLeast function example
package io
Golang io.ReadAtLeast function usage example
package main
import (
"fmt"
"io"
"strings"
)
func main() {
reader := strings.NewReader("GoodBye World!")
buff := make([]byte, 32)
n, err := io.ReadAtLeast(reader, buff, 8) // read at least 8 bytes into buffer
fmt.Printf("\n%s ", buff)
fmt.Printf("\n Number of bytes copied : %d with error : %v", n, err)
}
Output :
GoodBye World!
Number of bytes copied : 14 with error :
Reference :
Advertisement
Something interesting
Tutorials
+7.2k Golang : Dealing with postal or zip code example
+5.6k Javascript : How to refresh page with JQuery ?
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+14.3k Golang : Get uploaded file name or access uploaded files
+10.3k Golang : Embed secret text string into binary(executable) file
+19.8k Golang : Append content to a file
+6.9k Golang : How to solve "too many .rsrc sections" error?
+12.7k Golang : Sort and reverse sort a slice of bytes
+12.5k Golang : Arithmetic operation with numerical slices or arrays example
+6.9k Android Studio : Hello World example
+10.2k Golang : How to get quoted string into another string?