Golang bytes.Reader.Len() function example
package bytes
Len returns the number of bytes of the unread portion of the slice.
Golang bytes.Reader.Len() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
reader := bytes.NewReader([]byte("abc"))
fmt.Println(reader.Len())
var b [2]byte
reader.Read(b[:])
// should be 1 after Read 2 bytes
fmt.Println(reader.Len())
}
Output :
3
1
Reference :
Advertisement
Something interesting
Tutorials
+14.5k Golang : Overwrite previous output with count down timer
+8.8k Yum Error: no such table: packages
+19.4k Golang : How to count the number of repeated characters in a string?
+6.9k Mac OSX : Find large files by size
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+10.9k Golang : Sieve of Eratosthenes algorithm
+8.2k Golang : Routes multiplexer routing example with regular expression control
+18.8k Golang : Delete duplicate items from a slice/array
+8.5k Golang : How to check variable or object type during runtime?
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+13.9k Golang : How to determine if a year is leap year?