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
+7.4k Android Studio : How to detect camera, activate and capture example
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+12.7k Golang : Remove or trim extra comma from CSV
+30.8k Golang : Download file example
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+12.6k Golang : Exit, terminating or aborting a program
+15.6k Golang : How to convert(cast) IP address to string?
+15.4k Golang : invalid character ',' looking for beginning of value
+15.6k Golang : rune literal not terminated error
+13.8k Golang : unknown escape sequence error
+41.9k Golang : How do I convert int to uint8?
+41.2k Golang : How to count duplicate items in slice/array?