util

package
v0.0.0-...-8666326 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2014 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package util contains utility functions used by multiple packages of elvish.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(d time.Duration) <-chan time.Time

After is like time.After, except that it interpretes negative Duration as "forever".

func CeilDiv

func CeilDiv(a, b int) int

CeilDiv computes ceil(float(a)/b) but does not actually use float arithmetics.

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

func FindContext(text string, pos int) (lineno, colno int, line string)

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 FindFirstEOL(s string) int

func FindLastSOL

func FindLastSOL(s string) int

func Getwd

func Getwd() string

Getwd returns path of the working directory in a format suitable as the prompt.

func MaxInt

func MaxInt(x0 int, xs ...int) int

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

func SocketName() (string, error)

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

Jump to

Keyboard shortcuts

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