mem

package
v0.0.0-...-e92691c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	sync.Mutex
	// contains filtered or unexported fields
}

File is a custom implementation of an in-memory file type It behaves as any io.{Reader,ReaderAt,Writer,WriterAt}

func NewFile

func NewFile(b []byte) *File

NewFile should be used for anything else

func WithFileSize

func WithFileSize(sz int64) *File

WithFileSize primes the buffer with provided size This should be used if we are writing to this file

func (*File) Bytes

func (f *File) Bytes() []byte

Bytes returns underlying buffer

func (*File) Close

func (f *File) Close() error

Close file by setting vars to nil

func (*File) Len

func (f *File) Len() int

Len returns the number of bytes currently stored in buffer

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface.

func (*File) Reset

func (f *File) Reset()

Reset creates new buffer

func (*File) Size

func (f *File) Size() int64

Size returns the size of the buffer

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

Wrtie copies b to buffer

func (*File) WriteAt

func (f *File) WriteAt(b []byte, off int64) (n int, err error)

WriteAt copies bytes at offset

Jump to

Keyboard shortcuts

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