util

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package util contains various general utility functions used throughout the project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(path string, writer io.Writer) error

CopyFile reads a file from disk and copies it into the writer

func HashBuffer

func HashBuffer(buf []byte) (string, error)

HashBuffer computes a truncated MD5 hash from a buffer

func IDToString

func IDToString(id int64) string

IDToString is a helper for converting a post ID to a string for JSON keys

func LogError

func LogError(ip string, err error)

LogError logs an error with its stack trace

func RandomID

func RandomID(length int) string

RandomID generates a randomID of uppercase and lowercase letters and numbers of desired length

func Waterfall

func Waterfall(fns []func() error) (err error)

Waterfall executes a slice of functions until the first error returned. This error, if any, is returned to the caller.

func WrapError

func WrapError(text string, err error) error

WrapError wraps error types to create compound error chains

Types

type AtomicCloser

type AtomicCloser struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

AtomicCloser is a simple boolean guarded by a mutex for atomically managing a shared close/open state from multiple goroutines. Can be safely emebedded into other structs.

func (*AtomicCloser) Close

func (a *AtomicCloser) Close()

Close closes AtomicCloser

func (*AtomicCloser) IsOpen

func (a *AtomicCloser) IsOpen() bool

IsOpen returns, if AtomicCloser is still open

Jump to

Keyboard shortcuts

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