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
+5.4k Golang : What is StructTag and how to get StructTag's value?
+8.1k Golang : How To Use Panic and Recover
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+8.8k Golang : Heap sort example
+5.8k Golang : Find change in a combination of coins example
+18.1k Golang : Check if a directory exist or not
+10.4k Golang : Generate random integer or float number
+5.3k Golang : Get FX sentiment from website example
+13.4k Golang : Increment string example
+11.7k Golang : How to detect a server/machine network interface capabilities?
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+4.7k Linux/MacOSX : How to symlink a file?