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.6k Golang : Detect words using using consecutive letters in a given string
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+6.9k Golang : Normalize email to prevent multiple signups example
+8.2k Android Studio : Rating bar example
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+8.3k Golang : Implementing class(object-oriented programming style)
+6.1k Golang : Missing Subversion command
+15k Golang : Search folders for file recursively with wildcard support
+10.6k Golang : Get local time and equivalent time in different time zone
+9.7k Golang : Detect number of active displays and the display's resolution
+16.5k Golang : Execute terminal command to remote machine example