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
+7.1k Golang : Gargish-English language translator
+6.2k Golang : Dealing with backquote
+12.7k Golang : Exit, terminating or aborting a program
+13.2k Golang : How to get a user home directory path?
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+11.2k Golang : Roll the dice example
+8.5k PHP : How to parse ElasticSearch JSON ?
+8.9k Golang : Take screen shot of browser with JQuery example
+7.8k Golang : Command line ticker to show work in progress
+5.1k Linux : How to set root password in Linux Mint
+8.6k Golang : How to check variable or object type during runtime?
+12.1k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example