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.5k Golang : Set, Get and List environment variables
+17.4k Golang : Multi threading or run two processes or more example
+9.8k Golang : Get current, epoch time and display by year, month and day
+13.6k Golang : Qt progress dialog example
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+7.1k Golang : Gorrila mux.Vars() function example
+13.4k Golang : Read from buffered reader until specific number of bytes
+48.5k Golang : Upload file from web browser to server
+4.8k PHP : Extract part of a string starting from the middle