utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPath is returned by Command if the program is not in the PATH.
	ErrPath = errors.New("program not in PATH")
	// ErrTimeout is returned by Command if the program timed out.
	ErrTimeout = errors.New("program killed after timeout")
)

Functions

func Command added in v0.2.0

func Command(timeout time.Duration, name string, arg ...string) ([]byte, error)

Command executes the named program with the given arguments. If it does not exit within timeout, it is sent SIGINT (if supported by Go). After another timeout, it is killed.

func DumpHeap added in v0.2.0

func DumpHeap()

func ExecuteTemplate

func ExecuteTemplate(tpl string, data interface{}, post_process func(string) string) (string, error)

FIXME: leaking param: data

func FindAllTemplateKeys

func FindAllTemplateKeys(tpl string) (res []string)

func GC added in v0.2.0

func GC()

func HttpPprofServe

func HttpPprofServe(port int)

func IsAlNum added in v0.2.0

func IsAlNum(s string) bool

IsAlNum returns true if s is alphanumeric.

func IsDigit added in v0.2.0

func IsDigit(s string) bool

IsDigit returns true if s consists of decimal digits.

func IsDirectory added in v0.2.0

func IsDirectory(path string) (bool, error)

func MustPositiveInterval added in v0.2.0

func MustPositiveInterval(interval string, dft time.Duration) time.Duration

FIXME: dft should also > 0

func PathExists

func PathExists(path string) (bool, error)

exists returns whether the given file or directory exists or not

func PrintGCSummary added in v0.2.0

func PrintGCSummary()

func ReadCommand added in v0.2.0

func ReadCommand(line func(string) error, name string, arg ...string) error

ReadCommand runs command name with args and calls line for each line from its stdout. Command is interrupted (if supported by Go) after 10 seconds and killed after 20 seconds.

func ReadCommandTimeout added in v0.2.0

func ReadCommandTimeout(timeout time.Duration, line func(string) error, name string, arg ...string) error

ReadCommandTimeout is the same as ReadCommand with a specifiable timeout.

func ReadLine added in v0.2.0

func ReadLine(fname string, line func(string) error) error

func Recover_and_log added in v0.2.0

func Recover_and_log()

func SetMemProfileRate added in v0.2.0

func SetMemProfileRate(rate int)

func ShowGCStat added in v0.2.0

func ShowGCStat()

func StartBlockProfile added in v0.2.0

func StartBlockProfile(rate int)

func StartCPUProfile added in v0.2.0

func StartCPUProfile()

func StopBlockProfile added in v0.2.0

func StopBlockProfile()

func StopCPUProfile added in v0.2.0

func StopCPUProfile()

Types

type SMA

type SMA struct {
	N int
	// contains filtered or unexported fields
}

func (*SMA) Calc

func (m *SMA) Calc(x float64) (float64, error)

FIXME: .\math_sma.go:15: leaking param: m

Jump to

Keyboard shortcuts

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