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) *ReaderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | String 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())}