Standard library / bufio
bufio.Reader.UnreadByte()
Makes the most recently read byte available again. Fails if the last operation is not a suitable read. Expected stdout: 'a <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Reader) UnreadByte() errorReturn Value
error
Makes the most recently read byte available again.
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { r := bufio.NewReader(strings.NewReader("ab")) r.ReadByte() e := r.UnreadByte() c, _ := r.ReadByte() fmt.Println(string(c), e)}