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.3k Golang : Calculate US Dollar Index (DXY)
+24.5k Golang : Time slice or date sort and reverse sort example
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+17.4k Golang : Check if IP address is version 4 or 6
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+15.4k Golang : invalid character ',' looking for beginning of value
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+17.1k Golang : XML to JSON example
+7.6k SSL : How to check if current certificate is sha1 or sha2 from command line
+13.7k Golang : Check if an integer is negative or positive
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+21.2k Golang : Clean up null characters from input data