Golang io.NewSectionReader function example
package io
Golang io.NewSectionReader function usage example
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
)
func main() {
reader := bytes.NewReader([]byte("abcdefghijklmnopqrstuvwxyz"))
// read from position 2 to 8
// remember...counting starts from zero
section := io.NewSectionReader(reader, 2, 8)
data, _ := ioutil.ReadAll(section)
fmt.Println(string(data))
}
Output :
cdefghij
Reference :
Advertisement
Something interesting
Tutorials
+8.9k Golang : Sort lines of text example
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+17k Golang : Covert map/slice/array to JSON or XML format
+7.9k Golang : Trim everything onward after a word
+13.8k Golang : Gin framework accept query string by post request example
+9.7k PHP : Get coordinates latitude/longitude from string
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+26.9k Golang : Force your program to run with root permissions
+7.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+6.9k Mac OSX : Find large files by size