utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 16 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// JSON .
	JSON = "JSON"
	// YAML .
	YAML = "YAML"
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func Confirmation

func Confirmation(writer io.Writer, description string) (bool, error)

Confirmation .

func Language

func Language(languageSource string, languageSources ...string) i18n.TranslateFunc

Language is a wrapper of go_i18n.Tfunc

func LoadLocales

func LoadLocales(path string) error

LoadLocales loads translation files

func MarshallReader

func MarshallReader(writer io.Writer, data interface{}, format string) error

MarshallReader returns the JSON or YAML encoding of data.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func ReadInputFile

func ReadInputFile(path string) (io.Reader, string, error)

ReadInputFile reads the content of a given file and retuns a reader and the extension of the file.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func ScannerLines

func ScannerLines(writer io.Writer, description string, instructions bool) (io.Reader, string, error)

ScannerLines returns a reader with the rules provided in the console.

func UnmarshalReader

func UnmarshalReader(data io.Reader, format string, dest interface{}) error

UnmarshalReader parses the reader data and stores the result in the value pointed by dest.

func ValidateRulesFormat

func ValidateRulesFormat(reader io.Reader) (io.Reader, error)

ValidateRulesFormat .

func YAMLToJSON

func YAMLToJSON(reader io.Reader, dst interface{}) (io.Reader, error)

YAMLToJSON converts the YAML data of a given reader to JSON, removes all insignificant characters and returns a new reader.

Types

This section is empty.

Jump to

Keyboard shortcuts

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