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
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+6.3k Golang : How to search a list of records or data structures
+5.3k Swift : Convert string array to array example
+11.1k Golang : Read until certain character to break for loop
+14.4k Golang : On enumeration
+9.7k Golang : Populate slice with sequential integers example
+51.9k Golang : How to get time in milliseconds?
+8.1k Golang : HTTP Server Example
+7.5k Golang : Shuffle strings array
+9.7k Golang : interface - when and where to use examples
+6.5k Golang : Spell checking with ispell example
+5.6k Python : Print unicode escape characters and string