fslayer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: MIT Imports: 4 Imported by: 1

README

Go file system abstraction

GoDoc Go Report Card

The package provides an abstraction over the file system using go-billy package. It exposes a single function Fs(), which provides the I/O methods for manipulating the files either on a persistent storage or in a memory, depending on how the package has been initialized.

The initialization should be performed during the application startup or the test initialization the following way:

import "github.com/umk/go-fslayer"

func main() {
	fslayer.UseStorageDevice(); // for persistent storage
	fslayer.UseMemoryStorage(); // to save files in memory
}

Either of these two functions may be called in a single process, and may be called just once. When called twice, the application will panic.

When trying to access the file system, use the following:

import . "github.com/umk/go-fslayer"

func DoSmth() {
	f, err := Fs().Open("/foo/bar.txt")
	// ...
}

If Fs() is used without the storage type initialized, like shown before, the application will panic.

See this package's GoDoc reference and documentation for go-billy's osfs and memfs for the list of functions available.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseMemoryStorage

func UseMemoryStorage()

UseMemoryStorage instructs the application to use RAM for storing the configuration. The initialization must be performed exactly once during startup.

func UseStorageDevice

func UseStorageDevice()

UseStorageDevice instructs the application to use storage device for storing the configuration. The initialization must be performed exactly once during startup.

Types

type Storage

type Storage interface {
	billy.Filesystem
	RemoveAll(path string) error
}

Extends the file system abstraction with new methods.

func Fs

func Fs() Storage

Fs gets the root file system object.

Jump to

Keyboard shortcuts

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