Golang bytes.Reader.ReadAt() function example
package bytes
Golang bytes.Reader.ReadAt() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
reader := bytes.NewReader([]byte("abc"))
var b [3]byte
n, err := reader.ReadAt(b[:], 2) // start reading at offset/position 2
// should print the character c
fmt.Printf("%d %v %s \n", n, err, string(b[:]))
}
Output :
1 EOF c
Reference :
Advertisement
Something interesting
Tutorials
+22k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+13.4k Golang : Strings comparison
+9.8k Golang : Function wrapper that takes arguments and return result example
+4.8k JQuery : Calling a function inside Jquery(document) block
+24.4k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+12.6k Golang : Add ASCII art to command line application launching process
+20.4k Nginx + FastCGI + Go Setup.
+13.5k Golang : reCAPTCHA example
+6.5k Golang : How to determine if request or crawl is from Google robots
+8.1k Golang : Find relative luminance or color brightness
+9.9k Golang : Translate language with language package example
+9.1k Golang : Create and shuffle deck of cards example