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
+21.5k Golang : How to read float value from standard input ?
+52.6k Golang : How to get struct field and value by name
+18.3k Golang : Get path name to current directory or folder
+26.8k Golang : Find files by extension
+12.4k Golang : Extract part of string with regular expression
+4.9k Unix/Linux : secure copying between servers with SCP command examples
+11.8k Golang : Verify Linux user password again before executing a program example
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+9.1k Golang : Simple histogram example
+9.6k Golang : Quadratic example
+4.7k Adding Skype actions such as call and chat into web page examples
+12.7k Golang : Add ASCII art to command line application launching process