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.3k Golang : Get uploaded file name or access uploaded files
+6.6k Golang : Warp text string by number of characters or runes example
+7.7k Golang : Error reading timestamp with GORM or SQL driver
+6.1k Golang : Scan forex opportunities by Bollinger bands
+7k Golang : Gargish-English language translator
+12.2k Golang : Get remaining text such as id or filename after last segment in URL path
+6.2k Linux/Unix : Commands that you need to be careful about
+18.5k Golang : Set, Get and List environment variables
+16.9k Golang : Set up source IP address before making HTTP request
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+6.8k Golang : Get expvar(export variables) to work with multiplexer