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
+14.5k Golang : How to determine if user agent is a mobile device example
+6.9k Android Studio : Hello World example
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+8.3k Golang: Prevent over writing file with md5 hash
+16.3k Golang : Find out mime type from bytes in buffer
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+13.9k Golang : Get dimension(width and height) of image file
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+13k Golang : Calculate elapsed years or months since a date
+12.8k Golang : http.Get example
+5.7k Golang : Struct field tags and what is their purpose?