util

package
v0.0.0-...-18867cc Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = errors.New("could not detect file")

Returned when the .gopath file is not found.

View Source
var GiloBinary = BinaryResolverFunc(giloBinary)

GiloBinary - Returns the directory of the gilo binary. Checks the GILOBIN environment variable for a user specified value. Otherwise defaults to $HOME/.gilo/bin

Functions

func JoinPaths

func JoinPaths(paths ...string) string

JoinPaths - Joins the paths together

func MustWorkingDirectory

func MustWorkingDirectory() string

MustWorkingDirectory - returns the current working directory. or panics.

Types

type BinaryResolver

type BinaryResolver interface {
	Path() (string, error)
}

BinaryResolver - Used to find the paths to a binary

type BinaryResolverFunc

type BinaryResolverFunc func() (string, error)

BinaryResolverFunc - adapter function allowing pure functions to act as a BinaryResolver

func (BinaryResolverFunc) Path

func (t BinaryResolverFunc) Path() (string, error)

Path - Returns path computed by the function.

type ConstantResolver

type ConstantResolver string

ConstantResolver - This resolver is for test cases.

func (ConstantResolver) Find

func (t ConstantResolver) Find(name string) (string, error)

Find - Always returns the same base directory path for a requested file. (Even if that file doesn't exist)

type ErroringResolver

type ErroringResolver struct {
	Err error
}

ErroringResolver - This resolver is for test cases.

func (ErroringResolver) Find

func (t ErroringResolver) Find(name string) (string, error)

Find - errors out

type FileResolver

type FileResolver interface {
	Find(name string) (string, error)
}

FileResolver - Interface for resolving configuration file

type PathMunger

type PathMunger interface {
	Strip(path string) string
	Replace(pattern string, replacement string) string
	Prepend(path string) string
}

PathMunger - Utility methods for manipulating os paths.

type RecursiveResolver

type RecursiveResolver struct {
	Directory string
}

RecursiveResolver - FileResolver that recurses up the directory tree.

func (RecursiveResolver) Find

func (t RecursiveResolver) Find(name string) (string, error)

Find - Searches parent directories for the specified file until either 1) file is found or 2) root directory is reached. Will return a could not detect file error if the root directory is reached.

type UnixPathMunger

type UnixPathMunger string

UnixPathMunger - Unix implementation of the path munger.

func (UnixPathMunger) Prepend

func (t UnixPathMunger) Prepend(path string) string

Prepend - Prepends the specified path to the Path Munger

func (UnixPathMunger) Replace

func (t UnixPathMunger) Replace(pattern string, replacement string, n int) string

Replace - replaces the supplied pattern with replacement string within the path up to n times.

func (UnixPathMunger) Strip

func (t UnixPathMunger) Strip(subpath string) string

Strip - Strips the specified subpath from the path.

Jump to

Keyboard shortcuts

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