Documentation ¶
Overview ¶
Package xopen makes it easy to get buffered readers and writers. Ropen opens a (possibly gzipped) file/process/http site for buffered reading. Wopen opens a (possibly gzipped) file for buffered writing. Both will use gzip when appropriate and will user buffered IO.
Index ¶
- Variables
- func CheckBytes(b *bufio.Reader, buf []byte) (bool, error)
- func Exists(path string) bool
- func ExpandUser(path string) (string, error)
- func IsBzip2(b *bufio.Reader) (bool, error)
- func IsGzip(b *bufio.Reader) (bool, error)
- func IsStdin() bool
- func IsXz(b *bufio.Reader) (bool, error)
- func IsZst(b *bufio.Reader) (bool, error)
- func XReader(f string) (io.Reader, error)
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrDirNotSupported = errors.New("xopen: input is a directory")
ErrDirNotSupported means the path is a directory.
var ErrNoContent = errors.New("xopen: no content")
ErrNoContent means nothing in the stream/file.
var Level = gzip.DefaultCompression
Level is the default compression level of gzip. This value will be automatically adjusted to the default value of zstd or bzip2.
Functions ¶
func CheckBytes ¶
CheckBytes peeks at a buffered stream and checks if the first read bytes match.
func ExpandUser ¶
ExpandUser expands ~/path and ~otheruser/path appropriately
Types ¶
type Reader ¶
Reader is returned by Ropen
type Writer ¶
Writer is returned by Wopen
func Wopen ¶
Wopen opens a buffered reader. If f == "-", then stdout will be used. If f endswith ".gz", then the output will be gzipped. If f endswith ".xz", then the output will be zx-compressed. If f endswith ".zst", then the output will be zstd-compressed. If f endswith ".bz2", then the output will be bzip2-compressed.