Documentation
¶
Index ¶
- type Appender
- type File
- func (f *File) Appender() *Appender
- func (f *File) Close() error
- func (f *File) Fd() int
- func (f *File) ForceClose() error
- func (f *File) Name() string
- func (f *File) Read(b []byte) (n int, err error)
- func (f *File) ReadAt(b []byte, off int64) (n int, err error)
- func (f *File) ReadFrom(rd io.Reader) (n int64, err error)
- func (f *File) Reader() *Reader
- func (f *File) ReaderAt(off int64) *Reader
- func (f *File) SectionReader(off, n int64) *Reader
- func (f *File) Size() int64
- func (f *File) Stat() (fi os.FileInfo, err error)
- func (f *File) Truncate(sz int64) (err error)
- func (f *File) With(fn func(*os.File) error) (err error)
- func (f *File) Write(b []byte) (n int, err error)
- func (f *File) WriteAt(b []byte, off int64) (n int, err error)
- func (f *File) WriteTo(w io.Writer) (n int64, err error)
- func (f *File) Writer() *Writer
- func (f *File) WriterAt(off int64) *Writer
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
SyncAfterWriterClose bool // if set to true, calling `Writer.Close()`, will call `*os.File.Sync()`.
// contains filtered or unexported fields
}
File is an `*os.File` wrapper that allows multiple readers or one writer or appender on a single file descriptor.
func FromFile ¶
FromFile returns a `*File` from an `*os.File`. Using `f.Writer` requires that the file to *not* be opened with os.O_APPEND. On success, the returned `*File` will handle closing the `*os.File`.
func TempFile ¶
TempFile is a convenience wrapper for `ioutil.TempFile`. Remember to clean up by calling `os.Remove(f.Name())` when you're done.
func (*File) Close ¶
Close waits for all the active readers/writer to finish before closing the underlying `*os.File`.
func (*File) ForceClose ¶
ForceClose will close the underlying `*os.File` without waiting for any active readers/writer.
func (*File) SectionReader ¶
SectionReader returns a SectionReader that reads from f starting at offset off and stops with EOF after n bytes. if n - 1, it will read the entire file.
func (*File) Size ¶
Size returns the current file size. the size is cached after each writer is closed, so it doesn't call Stat().
func (*File) Stat ¶
Stat calls the underlying `*os.File.Stat()`. Will block if there are any active appenders or writers.
func (*File) With ¶
With acquires a write lock and calls fn with the underlying `*os.File` and returns any errors it returns.
func (*File) Write ¶
Write wraps `f.Appender().Write` for convenience. If expecting multiple `Write` calls, use `f.Appender()“ directly.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements `io.Reader`, `io.ReaderAt`, `io.Seeker` and `io.Closer`.