Documentation ¶
Overview ¶
Package util contains utility functions used by multiple packages of elvish.
Index ¶
- func After(d time.Duration) <-chan time.Time
- func CeilDiv(a, b int) int
- func DeepPrint(x interface{}) string
- func FindContext(text string, pos int) (lineno, colno int, line string)
- func FindFirstEOL(s string) int
- func FindLastSOL(s string) int
- func Getwd() string
- func MaxInt(x0 int, xs ...int) int
- func Panic(err error)
- func Recover(perr *error)
- func SocketName() (string, error)
- type AsyncReader
- type ContextualError
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepPrint ¶
func DeepPrint(x interface{}) string
DeepPrint is like printing with the %#v formatter of fmt, but it prints pointer fields recursively.
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 ¶
func FindLastSOL ¶
func Getwd ¶
func Getwd() string
Getwd returns path of the working directory in a format suitable as the prompt.
func Panic ¶
func Panic(err error)
Panic panics with err wrapped properly so that it can be catched by Recover.
func Recover ¶
func Recover(perr *error)
Recover tries to catch an error thrown by Panic and stop the panic. If the panic is not caused by Panic, the panic is not stopped.
func SocketName ¶
SocketName returns the path of the per-user Unix socket elvish and elvishd use for communication.
Types ¶
type AsyncReader ¶
type AsyncReader struct {
// contains filtered or unexported fields
}
AsyncReader delivers a Unix fd stream to a channel of runes.
func NewAsyncReader ¶
func NewAsyncReader(rd *os.File) *AsyncReader
func (*AsyncReader) Chan ¶
func (ar *AsyncReader) Chan() <-chan rune
func (*AsyncReader) Continue ¶
func (ar *AsyncReader) Continue()
func (*AsyncReader) Quit ¶
func (ar *AsyncReader) Quit()
func (*AsyncReader) Stop ¶
func (ar *AsyncReader) Stop()
type ContextualError ¶
type ContextualError struct {
// contains filtered or unexported fields
}
func NewContextualError ¶
func NewContextualError(name string, text string, pos int, format string, args ...interface{}) *ContextualError
func (*ContextualError) Error ¶
func (e *ContextualError) Error() string
func (*ContextualError) Pprint ¶
func (e *ContextualError) Pprint() string
Notes ¶
Bugs ¶
AsyncReader relies on the undocumented fact that (*os.File).Read returns an *os.File.PathError