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
+18.6k Golang : Get download file size
+14.9k Golang : Submit web forms without browser by http.PostForm example
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+20.7k Golang : Saving private and public key to files
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+22.1k Golang : Join arrays or slices example
+33k Golang : How to check if a date is within certain range?
+15.2k Golang : Get HTTP protocol version example
+13.6k Golang : Get user input until a command or receive a word to stop
+11.1k Golang : Roll the dice example
+27.2k Golang : Find files by name - cross platform example