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
+11.2k Golang : How to pipe input data to executing child process?
+11.2k CodeIgniter : How to check if a session exist in PHP?
+7k Golang : constant 20013 overflows byte error message
+17.9k Golang : Login and logout a user after password verification and redirect example
+22.7k Golang : Strings to lowercase and uppercase example
+12k Golang : Clean formatting/indenting or pretty print JSON result
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+6.9k Golang : Normalize email to prevent multiple signups example
+11.3k Golang : Post data with url.Values{}
+31.9k Golang : Convert an image file to []byte
+21.2k Golang : Get password from console input without echo or masked
+26.1k Mac/Linux and Golang : Fix bind: address already in use error