idemvfs

package module
v0.0.0-...-aba1e2e Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

idemvfs

idemvfs is a package built on top of vfsgen that provides consistent modification times.

Documentation

Overview

Package idemvfs implements a virtual file system that guarantees idempotency of modification time when a file's content is identical to the stored state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(i1, i2 Identity) bool

Equal returns true when the 2 files match.

func Generate

func Generate(fs http.FileSystem, opts Options) error

Generate Go code that records the modification time, checksum and size for all files found in the given http.FileSystem.

Types

type EmptyIdentifier

type EmptyIdentifier struct{}

EmptyIdentifier implements Identifier, it always returns false.

func (EmptyIdentifier) Identify

func (n EmptyIdentifier) Identify(_ string) (Identity, bool)

Identify implements the Identifier interface.

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

FileSystem implements the http.FileSystem interface. It returns idempotent modification times if the actual file's identity matches with the information returned by Identifier.

func NewFileSystem

func NewFileSystem(fs http.FileSystem, i Identifier) *FileSystem

NewFileSystem creates a new FileSystem.

func (*FileSystem) Open

func (s *FileSystem) Open(name string) (http.File, error)

Open implements the http.FileSystem interface.

type Identifier

type Identifier interface {
	Identify(name string) (Identity, bool)
}

Identifier returns the identity of a file given its name. It should return false if the file is unknown.

type Identity

type Identity interface {
	Checksum() []byte
	ModTime() time.Time
	Size() int64
}

Identity defines the methods that represent the identity of a file.

type Options

type Options struct {
	// Filename of the generated Go code output (including the extension).
	// If left empty, it defaults to "{{toLower .VariableName}}.go".
	Filename string

	// PackageName is the name of the package in the generating program.
	// If left empty, it default to "name".
	PackageName string

	// VariableName is the name of the Identifier variable in the generating program.
	// If left empty, it default to "identifier".
	VariableName string
}

Options for the Generate function.

Jump to

Keyboard shortcuts

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