Documentation ¶
Overview ¶
Package io extends the standard io library.
DEPRECATED: This package has been merged into package lib/os and will be removed in the next six release v0.51.0.
Index ¶
- func ConfirmYesNo(in io.Reader, msg string, defIsYes bool) bool
- func Copy(out, in string) (err error)
- func IsBinary(file string) bool
- func IsDirEmpty(dir string) (ok bool)
- func IsFileExist(parent, relpath string) bool
- func RmdirEmptyAll(path string) error
- type Reader
- func (r *Reader) Current() byte
- func (r *Reader) Init(src []byte)
- func (r *Reader) ReadLine() (line []byte)
- func (r *Reader) ReadUntil(seps, terms []byte) (tok []byte, isTerm bool, c byte)
- func (r *Reader) ReplaceAll(old, new []byte)
- func (r *Reader) Rest() []byte
- func (r *Reader) ScanInt64() (n int64, c byte)
- func (r *Reader) SkipHorizontalSpace() (n int, c byte)
- func (r *Reader) SkipLine()
- func (r *Reader) SkipN(n int) bool
- func (r *Reader) SkipSpaces() (c byte)
- func (r *Reader) SkipUntil(seps []byte) (c byte)
- func (r *Reader) String() string
- func (r *Reader) UnreadN(n int) byte
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfirmYesNo ¶
ConfirmYesNo display a question to standard output and read for answer from input Reader for simple yes "y" or no "n" answer. If input Reader is nil, it will set to standard input. If "defIsYes" is true and answer is empty (only new line), then it will return true.
func Copy ¶ added in v0.13.0
Copy file from in to out. If the output file is already exist, it will be truncated. If the file is not exist, it will created with permission set to user's read-write only.
DEPRECATED: moved to lib/os#Copy.
func IsBinary ¶ added in v0.7.0
IsBinary will return true if content of file is binary. If file is not exist or there is an error when reading or closing the file, it will return false.
DEPRECATED: moved to [lib/os#IsBinary].
Example ¶
fmt.Println(IsBinary("/bin/bash")) fmt.Println(IsBinary("io.go"))
Output: true false
func IsDirEmpty ¶
IsDirEmpty will return true if directory is not exist or empty; otherwise it will return false.
DEPRECATED: moved to [lib/os#IsDirEmpty].
func IsFileExist ¶
IsFileExist will return true if relative path is exist on parent directory; otherwise it will return false.
DEPRECATED: moved to [lib/os#IsFileExist].
func RmdirEmptyAll ¶
RmdirEmptyAll remove directory in path if it's empty until one of the parent is not empty.
DEPRECATED: moved to [lib/os#RmdirEmptyAll].
Types ¶
type Reader ¶
type Reader struct { V []byte // V contains the buffer. X int // X contains the current index of readed buffer. }
Reader represent a buffered reader that use an index to move through slice of bytes.
The following illustration show the uses of each fields,
+-+-+-+-+-+ | | | | | | <= r.V +-+-+-+-+-+ ^ | r.X
func (*Reader) ReadUntil ¶
ReadUntil read the content of buffer until one of separator found, or until one of terminator character found, or until EOF. If terminator found, the returned isTerm value will be true, and c value will be the character that cause the termination.
func (*Reader) ReplaceAll ¶ added in v0.45.0
ReplaceAll replace all occurence of old with new, start from the current index.
func (*Reader) ScanInt64 ¶
ScanInt64 convert textual representation of number into int64 and return it. Any spaces before actual reading of text will be ignored. The number may prefixed with '-' or '+', if its '-', the returned value must be negative.
On success, c is non digit character that terminate scan, if its 0, its mean EOF.
func (*Reader) SkipHorizontalSpace ¶
SkipHorizontalSpace read until no space, carriage return, or tab occurred on buffer. On EOF it will return 0.
func (*Reader) SkipSpaces ¶
SkipSpaces read until no white spaces found and return the first byte that is not white spaces. On EOF, it will return 0.