util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2016 License: MIT Imports: 7 Imported by: 93

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalPath added in v0.6.0

func CanonicalPath(path string, basePath string) (string, error)

Return the canonical version of the given path, relative to the given base path. That is, if the given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.

func CanonicalPaths added in v0.6.0

func CanonicalPaths(paths []string, basePath string) ([]string, error)

Return the canonical version of the given paths, relative to the given base path. That is, if a given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.

func CreateLogger added in v0.6.0

func CreateLogger(prefix string) *log.Logger

Create a logger with the given prefix

func FileExists

func FileExists(path string) bool

Return true if the given file exists

func GetPathRelativeTo added in v0.4.0

func GetPathRelativeTo(path string, basePath string) (string, error)

Return the relative path you would have to take to get from basePath to path

func Grep

func Grep(regex *regexp.Regexp, glob string) (bool, error)

Returns true if the given regex can be found in any of the files matched by the given glob

func ListContainsElement added in v0.6.0

func ListContainsElement(list []string, element string) bool

Return true if the given list contains the given element

func ReadFileAsString added in v0.4.0

func ReadFileAsString(path string) (string, error)

Return the contents of the file at the given path as a string

func RemoveElementFromList added in v0.6.0

func RemoveElementFromList(list []string, element string) []string

Return a copy of the given list with all instances of the given element removed

Types

This section is empty.

Jump to

Keyboard shortcuts

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