util

package
Version: v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2011 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const IdBits = 64

Sufficient for 10**6 simultaneous IDs with probability of collision less than 10**-7.

Variables

View Source
var (
	LogWriter io.Writer = NullWriter{}
)

Logging

Functions

func MustOpen

func MustOpen(name string, flag int, perm uint32) *os.File

MustOpen is like os.Open but panics if the file cannot be opened. It simplifies safe initialization of global variables holding file descriptors.

func NewLogger

func NewLogger(format string, a ...interface{}) *log.Logger

func Packi64

func Packi64(b []byte, n int64)

func RandBytes

func RandBytes(b []byte)

func RandHexString

func RandHexString(bits int) string

func RandId

func RandId() string

Generates a random string with IdBits bits of entropy. The string will contain only the characters [0-9a-f] and dot, formatted for easier reading.

func Unpacki64

func Unpacki64(b []byte) (n int64)

Types

type NullWriter

type NullWriter struct{}

func (NullWriter) Write

func (nw NullWriter) Write(p []byte) (int, os.Error)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL