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
+16.4k Golang : Send email and SMTP configuration example
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+11.1k Golang : Read until certain character to break for loop
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+9k Golang : Go as a script or running go with shebang/hashbang style
+10k Golang : Channels and buffered channels examples
+14.8k Golang : Find commonalities in two slices or arrays example
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+9.4k Golang : Generate EAN barcode
+13.6k Golang : Get user input until a command or receive a word to stop
+13.9k Generate salted password with OpenSSL example
+17.5k Golang : Find smallest number in array