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
+32.3k Golang : Convert []string to []byte examples
+11.1k Golang : Create Temporary File
+16k Golang : Get current time from the Internet time server(ntp) example
+10.8k Android Studio : Simple input textbox and intercept key example
+17.3k Golang : Capture stdout of a child process and act according to the result
+37.7k Upload multiple files with Go
+29.5k Golang : JQuery AJAX post data to server and send data back to client example
+11.4k Golang : Byte format example
+8.3k Golang : Check from web if Go application is running or not
+9.4k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+4.8k Javascript : Access JSON data example