Documentation ¶
Index ¶
- Constants
- Variables
- func CopyFile(source, dest string) error
- func CopyFilesToDir(dir string, files []string, toDir string, flatten bool) error
- func DirExists(dir string) bool
- func ExpandUserHome(path string) string
- func FileExists(file string) bool
- func FileIsExecutable(file string) bool
- func FindFiles(dir string, includes, excludes []string, folder bool) ([]string, error)
- func FindInPath(executable string) []string
- func IsMap(object interface{}) bool
- func IsSlice(object interface{}) bool
- func ListContains(list []string, name string) bool
- func MaxLineLength(lines []string) int
- func MoveFilesToDir(dir string, files []string, toDir string, flatten bool) error
- func PathToUnix(path string) string
- func PathToWindows(path string) string
- func ReadFile(file string) ([]byte, error)
- func RemoveBlankLines(text string) string
- func TerminalWidth() int
- func ToMapStringInterface(object interface{}) (map[string]interface{}, error)
- func ToMapStringString(object interface{}) (map[string]string, error)
- func ToSliceString(object interface{}) ([]string, error)
- func ToString(object interface{}) (string, error)
- func Windows() bool
- type Object
- func (object Object) CheckFields(fields []string) error
- func (object Object) Copy() Object
- func (object Object) Fields() []string
- func (object Object) GetBoolean(field string) (bool, error)
- func (object Object) GetInteger(field string) (int, error)
- func (object Object) GetList(field string) ([]interface{}, error)
- func (object Object) GetListStrings(field string) ([]string, error)
- func (object Object) GetListStringsOrString(field string) ([]string, error)
- func (object Object) GetMapStringString(field string) (map[string]string, error)
- func (object Object) GetObject(field string) (Object, error)
- func (object Object) GetString(field string) (string, error)
- func (object Object) HasField(field string) bool
- func (object Object) ToMapStringString() (map[string]string, error)
Constants ¶
const ( // FileMode is default file mode FileMode = 0644 // DirFileMode is default directory file mode DirFileMode = 0755 )
const (
// DefaultTerminalWidth is the terminal width when undefined
DefaultTerminalWidth = 80
)
Variables ¶
var GOOS = runtime.GOOS
GOOS is the OS name
Functions ¶
func CopyFile ¶
CopyFile copies source file to destination, preserving mode: - source: the source file - dest: the destination file Return: error if something went wrong
func CopyFilesToDir ¶
CopyFilesToDir copies files in root directory to destination directory: - dir: root directory - files: globs of source files - toDir: destination directory - flatten: tells if files should be flatten in destination directory Return: an error if something went wrong
func DirExists ¶
DirExists tells if directory exists: - dir: directory to test Return: a boolean that tells if directory exists
func ExpandUserHome ¶
ExpandUserHome expand path starting with "~/": - path: the path to expand Return: expanded path
func FileExists ¶
FileExists tells if given file exists: - file: the name of the file to test Return: a boolean that tells if file exists
func FileIsExecutable ¶
FileIsExecutable tells if given file is executable by user: - file: file to test Return: a boolean that tells if file is executable by user
func FindFiles ¶
FindFiles finds files in the context: - dir: the search root directory (current dir if empty) - includes: the list of globs to include - excludes: the list of globs to exclude - folder: tells if we should include folders Return the list of files as a slice of strings
func FindInPath ¶
FindInPath search given executable in PATH: - executable: executable to search. Return: list of directories containing executable
func IsMap ¶
func IsMap(object interface{}) bool
IsMap tells if given object is a map: - object: object to examine Return: a boolean that tells if object is a map
func IsSlice ¶
func IsSlice(object interface{}) bool
IsSlice tells if given object is a slice: - object: object to examine Return: a boolean that tells if object is a slice
func ListContains ¶
ListContains tells if a list contains given string
func MaxLineLength ¶
MaxLineLength returns the maximum length of given lines: - lines: lines to examine Return: maximum length of lines as an integer
func MoveFilesToDir ¶
MoveFilesToDir moves files in source directory to destination: - dir: root directory of source files - files: globs of files to move - toDir: destination directory - flatten: tells if files should be flatten in destination directory Return: an error if something went wrong
func PathToUnix ¶
PathToUnix turns a path to Unix format (with "/"): - path: path to turn to unix format Return: converted path
func PathToWindows ¶
PathToWindows turns a path to Windows format (with "\"): - path: path to turn to windows format Return: converted path
func ReadFile ¶
ReadFile reads given file and return it as a byte slice: - file: the file to read Return: - content as a slice of bytes - an error if something went wrong
func RemoveBlankLines ¶
RemoveBlankLines removes blank lines of given string: - text: to text to process Return: a string without blank lines
func ToMapStringInterface ¶
ToMapStringInterface return interface as a map with string keys and interface values: - object: the maps of interfaces as an interface Return: - converted map of interfaces - an error if something went wrong
func ToMapStringString ¶
ToMapStringString return interface as a map with string keys and values: - object: the maps of strings as an interface Return: - converted map of strings - an error if something went wrong
func ToSliceString ¶
ToSliceString return interface as a slice of strings: - object: the slice of strings or string as an interface Return: - converted slice of strings - an error if something went wrong
Types ¶
type Object ¶
type Object map[string]interface{}
Object is a dictionary of interfaces
func NewObject ¶
NewObject makes an object from an interface: - thing: the thing to convert to an object Return: - converted object - an error if something went wrong
func (Object) CheckFields ¶
CheckFields checks that object has no field whose name is not in given list: - fields: list of fields to check Return: an error if something went wrong
func (Object) GetBoolean ¶
GetBoolean returns an object field as a boolean: - field: name of the field to get Return: - boolean content of the field - an error if something went wrong
func (Object) GetInteger ¶
GetInteger returns an object field as a integer: - field: name of the field to get Return: - integer content of the field - an error if something went wrong
func (Object) GetList ¶
GetList returns an object field as a slice of interfaces: - field: name of the field to get Return: - content of the field as a slice of interfaces - an error if something went wrong
func (Object) GetListStrings ¶
GetListStrings returns an object field as a slice of strings: - field: name of the field to get Return: - content of the field as a slice of strings - an error if something went wrong
func (Object) GetListStringsOrString ¶
GetListStringsOrString returns an object field as a slice of strings: - field: name of the field to get Return: - content of the field as a slice of strings - an error if something went wrong
func (Object) GetMapStringString ¶
GetMapStringString returns an object field as a map with string keys and values: - field: name of the field to get Return: - content of the field map with string keys and values - an error if something went wrong
func (Object) GetObject ¶
GetObject returns an object field as an object: - field: name of the field to get Return: - content of the field as an object - an error if something went wrong
func (Object) GetString ¶
GetString returns an object field as a string: - field: name of the field to get Return: - string content of the field - an error if something went wrong