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
+11.2k Golang : How to pipe input data to executing child process?
+9.6k Golang : Quadratic example
+10.4k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+17.7k Golang : [json: cannot unmarshal object into Go value of type]
+28k Golang : Move file to another directory
+12k Golang : Clean formatting/indenting or pretty print JSON result
+18k Golang : Get all upper case or lower case characters from string example
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+7.3k Golang : How to iterate a slice without using for loop?
+9.9k Golang : Turn string or text file into slice example
+14.4k Golang : How to pass map to html template and access the map's elements
+41.9k Golang : How do I convert int to uint8?