Golang strings.NewReader() function example
package strings
Golang strings.NewReader() function usage example
package main
import (
"fmt"
"strings"
)
func main() {
str := "HTTP/1.1 204 No Content\r\n\r\n"
reader := strings.NewReader(str)
l := reader.Len()
n, err := reader.Read([]byte("HTTP"))
if err != nil {
fmt.Println(err)
}
fmt.Println("Reader length is : ", l)
fmt.Println("Bytes read : ", n)
}
Output :
Reader length is : 27
Bytes read : 4
References :
http://golang.org/pkg/strings/#NewReader http://golang.org/pkg/strings/#Reader.Len http://golang.org/pkg/strings/#Reader.Read
Advertisement
Something interesting
Tutorials
+9.8k Golang : interface - when and where to use examples
+7k Golang : Normalize email to prevent multiple signups example
+11.4k Golang : How to use if, eq and print properly in html template
+11.8k Golang : Gorilla web tool kit secure cookie example
+26.5k Golang : Convert(cast) string to uint8 type and back to string
+16k Golang : ROT47 (Caesar cipher by 47 characters) example
+18.8k Golang : convert int to string
+13.5k Golang : Verify token from Google Authenticator App
+8.4k Golang : Check if integer is power of four example
+5.1k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+14.2k Golang : syscall.Socket example