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
+12.3k Golang : List running EC2 instances and descriptions
+19.3k Golang : Get RGBA values of each image pixel
+29.5k Golang : Login(Authenticate) with Facebook example
+9.3k Golang : How to get garbage collection data?
+8.8k Golang : Gorilla web tool kit schema example
+13k Golang : Calculate elapsed years or months since a date
+8.3k Golang : Implementing class(object-oriented programming style)
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+29.3k Golang : Save map/struct to JSON or XML file
+4.7k Linux/MacOSX : How to symlink a file?
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+16.1k Golang : Generate universally unique identifier(UUID) example