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
+15.9k Golang : Update database with GORM example
+8.2k Golang : Reverse text lines or flip line order example
+14k Golang : concatenate(combine) strings
+7.1k Golang : Array mapping with Interface
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+23.1k Golang : simulate tail -f or read last line from log file example
+40.5k Golang : Convert to io.ReadSeeker type
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+4.7k JavaScript: Add marker function on Google Map
+19.2k Golang : Delete item from slice based on index/key position
+11.5k Golang : Generate DSA private, public key and PEM files example
+24.6k Golang : How to validate URL the right way