util

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2016 License: MIT Imports: 16 Imported by: 62

Documentation

Overview

Package util contains general purpose utility and logging functions.

Index

Constants

This section is empty.

Variables

View Source
var LogWriter io.Writer

LogWriter is the writer to which the logs are written

Functions

func Debug

func Debug(group string, format string, any ...interface{})

Debug writes a debug statement to stdout.

func Deprecate

func Deprecate(message string)

Deprecate writes a deprecation warning.

func Error

func Error(group string, format string, any ...interface{}) error

Error writes an error statement to stdout.

func FileExists

func FileExists(filename string) bool

FileExists determines if path exists

func FindUp

func FindUp(start, path string) string

FindUp finds a path up the tree. On sucess, it returns found path, else "".

func Info

func Info(group string, format string, any ...interface{})

Info writes an info statement to stdout.

func InfoColorful added in v2.0.9

func InfoColorful(group string, format string, any ...interface{})

InfoColorful writes an info statement to stdout changing colors on succession.

func Outdated

func Outdated(srcGlobs, destGlobs []string) bool

Outdated determines if ANY src has been modified after ANY dest.

For example: *.go.html -> *.go

If any go.html has changed then generate go files.

func PackageName

func PackageName(sourceFile string) (string, error)

PackageName determines the package name from sourceFile if it is within $GOPATH

func Panic

func Panic(group string, format string, any ...interface{})

Panic writes an error statement to stdout.

func PartitionKV added in v2.0.1

func PartitionKV(r io.Reader, prefix string, assignment string) ([]map[string]string, error)

PartitionKV partitions a reader then parses key-value meta using an assignment string.

Example

PartitionKV(buf.NewBufferString(`

--@ key=SelectUser
SELECT * FROM users;

`, "--@", "=") => [{"_kind": "key", "key": "SelectUser", "_body": "SELECT * FROM users;"}]

func Prompt

func Prompt(prompt string) string

Prompt prompts user for input with default value.

func PromptPassword

func PromptPassword(prompt string) string

PromptPassword prompts user for password input.

func StrTemplate

func StrTemplate(src string, data map[string]interface{}) (string, error)

StrTemplate reads a go template and writes it to dist given data.

func Template

func Template(src string, dest string, data map[string]interface{})

Template reads a go template and writes it to dist given data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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