Standard library / bufio
bufio.Scanner.Bytes()
Returns latest token bytes without allocating a new slice; storage may be overwritten by the next Scan. Expected stdout: 'abc\n'.
Formal Syntax & Structure
go syntaxgo
func (s *Scanner) Bytes() []byteReturn Value
[]byte
Returns latest token bytes without allocating a new slice; storage may be overwritten by the next Scan.
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { s := bufio.NewScanner(strings.NewReader("abc")) s.Scan() b := append([]byte(nil), s.Bytes()...) fmt.Println(string(b))}