bufio Standard Library


type Reader struct {
	buf          []byte
	rd           io.Reader // reader provided by the client
	r, w         int       // buf read and write positions
	err          error
	lastByte     int // last byte read for UnreadByte; -1 means invalid
	lastRuneSize int // size of last rune read for UnreadRune; -1 means invalid
// NewReader returns a new Reader whose buffer has the default size.
func NewReader(rd io.Reader) *Reader {
	return NewReaderSize(rd, defaultBufSize)
package main

import (

func main() {
	scanner := bufio.NewReader(os.Stdin)
	fmt.Print("Enter text: ")
	text,_ := scanner.ReadString('\n')
	fmt.Printf("You entered: %s", text)