Standard library / strings

strings.NewReader()

Creates a reader over the supplied immutable string. Supports seeking and ReaderAt. Expected stdout: '2 2\n'.

Formal Syntax & Structure

go syntaxgo
func NewReader(s string) *Reader

Parameters & Attributes

NameTypeDescription
sstringString to read from.

Return Value

*Reader

Creates a reader over the supplied immutable string. Supports seeking and ReaderAt.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  r := strings.NewReader("go")  fmt.Println(r.Len(), r.Size())}
Go Reference