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
+6.6k Golang : How to determine if request or crawl is from Google robots
+5.7k Get website traffic ranking with Similar Web or Alexa
+15k Golang : How do I get the local IP (non-loopback) address ?
+9.6k Golang : How to generate Code 39 barcode?
+30.9k error: trying to remove "yum", which is protected
+23.5k Golang : Read a file into an array or slice example
+9.6k Golang : Validate IPv6 example
+11.9k Golang : How to parse plain email text and process email header?
+14k Golang : Human readable time elapsed format such as 5 days ago
+11.6k Golang : Simple file scaning and remove virus example
+4.9k Unix/Linux : secure copying between servers with SCP command examples