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
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.
+22.7k Golang : Round float to precision example
+9.2k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+10k Golang : Channels and buffered channels examples
+19.4k Golang : Fix cannot download, $GOPATH not set error
+27.2k Golang : Find files by name - cross platform example
+6k Javascript : Get operating system and browser information
+7.1k Golang : Get Alexa ranking data example
+5.1k Linux : How to set root password in Linux Mint
+10.1k Golang : Print how to use flag for your application example
+5.4k Javascript : How to loop over and parse JSON data?