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.1k Golang : Save webcamera frames to video file
+11.3k Golang : How to use if, eq and print properly in html template
+30k Golang : Get time.Duration in year, month, week or day
+11.1k Golang : Roll the dice example
+24.5k Golang : Time slice or date sort and reverse sort example
+8.6k Golang : Set or add headers for many or different handlers
+7.6k SSL : How to check if current certificate is sha1 or sha2 from command line
+8.2k Golang : Find relative luminance or color brightness
+11.5k CodeIgniter : Import Linkedin data
+25.5k Golang : Generate MD5 checksum of a file
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+14.4k Golang : On enumeration