Standard library / bufio

bufio.Scanner.Text()

Returns the latest token as a newly allocated string; use Bytes when transient byte access suffices. Expected stdout: 'abc\n'.

Formal Syntax & Structure

go syntaxgo
func (s *Scanner) Text() string

Return Value

string

Returns the latest token as a newly allocated string; use Bytes when transient byte access suffices.

Working Example

Example Snippetgo
package main
import (  "bufio"  "fmt"  "strings")
func main() { s := bufio.NewScanner(strings.NewReader("abc\n")); s.Scan(); fmt.Println(s.Text()) }
Go Reference