transform

package
v0.0.0-...-1339caa Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHash

func ComputeHash(info os.FileInfo, path string, h hash.Hash) (interface{}, error)

ComputeHash applies the hash h to the file located at path. Returns a line of dashes for directories.

func DefaultFormatValue

func DefaultFormatValue(attr, path string, info os.FileInfo) (value interface{}, err error)

DefaultFormatValue returns the default format value for the provided attribute attr based on path and info.

func FindHash

func FindHash(name string) func() hash.Hash

FindHash returns a func to create a new hash based on the provided name.

func Format

func Format(p *FormatParams) (val interface{}, err error)

Format runs the respective format function on the provided parameters.

func Parse

func Parse(p *ParseParams) (val interface{}, err error)

Parse runs the associated modifier function for the provided parameters. Depending on the type of p.Value, we may recursively run this method on every element of the structure.

We're using reflect _quite_ heavily for this, meaning it's kind of unsafe, it'd be great if we could find another solution while keeping it as abstract as it is.

Types

type ErrNotImplemented

type ErrNotImplemented struct {
	Name      string
	Attribute string
}

ErrNotImplemented used for non-implemented modifier functions.

func (*ErrNotImplemented) Error

func (e *ErrNotImplemented) Error() string

type ErrUnsupportedFormat

type ErrUnsupportedFormat struct {
	Format    string
	Attribute string
}

ErrUnsupportedFormat used for unsupport arguments for FORMAT functions.

func (*ErrUnsupportedFormat) Error

func (e *ErrUnsupportedFormat) Error() string

type FormatParams

type FormatParams struct {
	Attribute string
	Path      string
	Info      os.FileInfo
	Value     interface{}

	Name string
	Args []string
}

FormatParams holds the params for a format-modifier function.

type ParseParams

type ParseParams struct {
	Attribute string
	Value     interface{}

	Name string
	Args []string
}

ParseParams holds the params for a parse-modifier function.

Jump to

Keyboard shortcuts

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