Documentation ¶
Overview ¶
Package util contains utility functions.
Index ¶
- Constants
- Variables
- func AllExecutables(paths []string, names chan<- string)
- func CatError(err error, more error) error
- func Catch(perr *error)
- func CeilDiv(a, b int) int
- func DeepPrint(x interface{}) string
- func DontSearch(exe string) bool
- func FindContext(text string, pos int) (lineno, colno int, line string)
- func FindFirstEOL(s string) int
- func FindLastSOL(s string) int
- func GetHome(uname string) (string, error)
- func GetLogger(prefix string) *log.Logger
- func Getwd() string
- func IsExecutable(path string) bool
- func MatchSubseq(s, pattern string) bool
- func NthRune(s string, n int) (rune, error)
- func RootStar() []string
- func Search(paths []string, exe string) (string, error)
- func SetOutputFile(fname string) error
- func SubstringByRune(s string, low, high int) (string, error)
- func Throw(err error)
- func TildeAbbr(path string) string
- type Errors
- type Exception
- type PosError
Constants ¶
const ( MaxUint = ^uint(0) MinUint = 0 MaxInt = int(MaxUint >> 1) MinInt = -MaxInt - 1 )
Variables ¶
var ( ErrNotExecutable = errors.New("not executable") ErrNotFound = errors.New("not found") )
var ErrIndexOutOfRange = errors.New("substring out of range")
ErrIndexOutOfRange is returned when out-of-range errors occur.
Functions ¶
func AllExecutables ¶
AllExecutables writes the names of all executable files in the search path to a channel.
func Catch ¶
func Catch(perr *error)
Catch tries to catch an error thrown by Throw and stop the panic. If the panic is not caused by Throw, the panic is not stopped.
func DeepPrint ¶
func DeepPrint(x interface{}) string
DeepPrint is like printing with the %#v formatter of fmt, but it prints pointer fields recursively.
func DontSearch ¶
DontSearch determines whether the path to an external command should be taken literally and not searched.
func FindContext ¶
FindContext takes a position in a text and finds its line number, corresponding line and column numbers. Line and column numbers are counted from 0. Used in diagnostic messages.
func FindFirstEOL ¶
FindFirstEOL returns the index of the first '\n'. When there is no '\n', the length of s is returned.
func FindLastSOL ¶
FindLastSOL returns an index just after the last '\n'.
func GetHome ¶
GetHome finds the home directory of a specified user. When given an empty string, it finds the home directory of the current user.
func Getwd ¶
func Getwd() string
Getwd returns path of the working directory in a format suitable as the prompt.
func IsExecutable ¶
IsExecutable determines whether path refers to an executable file.
func MatchSubseq ¶
MatchSubseq returns whether pattern is a subsequence of s.
func Search ¶
Search tries to resolve an external command and return the full (possibly relative) path.
func SetOutputFile ¶
func SubstringByRune ¶
SubstringByRune returns the range of the i-th rune (inclusive) through the j-th rune (exclusive) in s.