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
+22.1k Golang : Join arrays or slices example
+12k Golang : Find and draw contours with OpenCV example
+9.9k Golang : Function wrapper that takes arguments and return result example
+7.8k Golang : Scan files for certain pattern and rename part of the files
+6.9k Fix sudo yum hang problem with no output or error messages
+12.6k Golang : Transform comma separated string to slice example
+8.3k Golang: Prevent over writing file with md5 hash
+7.1k Golang : Squaring elements in array
+29.7k Golang : Record voice(audio) from microphone to .WAV file
+17.5k Golang : Find smallest number in array
+7.9k Golang Hello World Example
+15.9k Golang : Get current time from the Internet time server(ntp) example