nobufio

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package nobufio provides non-buffered io operations.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNoTerminal = errors.New("ReadPasswordStrict: Reader is not a terminal")

ErrNoTerminal is returned by ReadPasswordStrict when stdin is not a terminal

Functions

func ReadLine

func ReadLine(reader io.Reader) (value string, err error)

ReadLine reads the current line from the provided reader.

A line is considered to end when one of the following is encountered: '\r\n', '\n' or EOF or '\r' followed by EOF. Note that only a '\r' is not considered an end-of-line.

The returned line never contains the end-of-line markers, such as '\n' or '\r\n'. A line may be empty, however when only EOF is read, returns "", EOF.

Example
input := strings.NewReader("line1\nline2\r\n\n\r\nline5")

fmt.Println(ReadLine(input))
fmt.Println(ReadLine(input))
fmt.Println(ReadLine(input))
fmt.Println(ReadLine(input))
fmt.Println(ReadLine(input))
fmt.Println(ReadLine(input))
Output:

line1 <nil>
line2 <nil>
 <nil>
 <nil>
line5 <nil>
 EOF

func ReadPassword

func ReadPassword(reader io.Reader) (value string, err error)

ReadPassword is like ReadLine, except that it turns off terminal echo. When reader is not a terminal, behaves like ReadLine

func ReadPasswordStrict

func ReadPasswordStrict(reader io.Reader) (value string, err error)

ReadPasswordSrict is like ReadPassword, except that when reader is not a terminal, returns ErrNoTerminal.

func ReadRune

func ReadRune(reader io.Reader) (r rune, size int, err error)

ReadRune reads a single encoded Unicode character and returns the rune and its size in bytes. If no character is available, err will be set.

See io.RuneReader.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL