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
+5.2k Golang : Experimental Jawi programming language
+24.5k Golang : GORM read from database example
+5.4k Javascript : How to loop over and parse JSON data?
+6.9k Golang : Decode XML data from RSS feed
+9k Golang : Populate or initialize struct with values example
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+6.9k How to let Facebook Login button redirect to a particular URL ?
+9.6k Golang : Copy map(hash table) example
+13.8k Golang : Gin framework accept query string by post request example
+6.3k Golang : Calculate US Dollar Index (DXY)