datastore

package
v0.0.0-...-70253b2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TempFile

func TempFile(dir, prefix string, suffix string) (f *os.File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix and ending in suffix, opens the file for reading and writing, and returns the resulting *os.File. TempFile is a modified version of ioutil's TempFile that supports suffixes and uses a naive increment strategy, instead of random numbers, for uniqueness.

Types

type DataStore

type DataStore interface {
	ListEntries(string) ([]string, error)
	NewEntryWriteCloser(string) (io.WriteCloser, error)
	NewEntryReadCloser(string) (io.ReadCloser, error)
	RemoveEntry(string) error
	MoveEntry(string, string) error
}

DataStore represents a persistent data store for notebooks.

type FileStore

type FileStore struct {
	Dir string
}

FileStore implements DataStore using files and directories. Notebooks and sections within a notebook are represented by directories. Entries are represented by files.

func (FileStore) ListEntries

func (fs FileStore) ListEntries(prefix string) ([]string, error)

ListEntries returns the UIDs of each entry in the FileStore.

func (FileStore) NewEntryReadCloser

func (fs FileStore) NewEntryReadCloser(uid string) (io.ReadCloser, error)

NewEntryReadCloser opens an entry's underlying file and returns an io.ReadCloser.

func (FileStore) NewEntryWriteCloser

func (fs FileStore) NewEntryWriteCloser(uid string) (io.WriteCloser, error)

NewEntryWriteCloser opens or creates an entry's underlying file and returns an io.WriteCloser.

func (FileStore) Remove

func (fs FileStore) Remove(uid string) error

Remove removes an entry's underlying file from the FileStore.

func (FileStore) Rename

func (fs FileStore) Rename(srcUID, destUID string) error

Rename renames (moves) an entry's underlying file from srcUID to destUID within the FileStore.

Jump to

Keyboard shortcuts

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