utils

package
v0.0.0-...-5f4265e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 12 Imported by: 36

Documentation

Overview

Provides basic internal utilities for geard.

Index

Constants

This section is empty.

Variables

View Source
var EmptyReader = ioutil.NopCloser(bytes.NewReader([]byte{}))
View Source
var ErrContentMismatch = errors.New("File content does not match expected value")
View Source
var ErrLockTaken = errors.New("An exclusive lock already exists on the specified file.")

Functions

func AtomicReplaceLink(from, target string) error

func AtomicWriteToContentPath

func AtomicWriteToContentPath(path string, mode os.FileMode, value []byte) error

func CreateFileExclusive

func CreateFileExclusive(path string, mode os.FileMode) (*os.File, error)

func CreateFileOnce

func CreateFileOnce(path string, data []byte, perm os.FileMode) error

func EncodeUrlPath

func EncodeUrlPath(s string) string

func IsolateContentPath

func IsolateContentPath(base, id, suffix string) string

func IsolateContentPathWithPerm

func IsolateContentPathWithPerm(base, id, suffix string, perm os.FileMode) string

func LimitWriter

func LimitWriter(w io.Writer, n int64) io.Writer

func NewWriteFlusher

func NewWriteFlusher(w io.Writer) io.Writer

* Return an io.Writer that will flush after every write.

func OpenFileExclusive

func OpenFileExclusive(path string, mode os.FileMode) (*os.File, bool, error)

func TakePrefix

func TakePrefix(s string, prefix string) (string, bool)

func TakeSegment

func TakeSegment(path string) (string, string, bool)

func WriteToPathExclusive

func WriteToPathExclusive(path string, source io.WriterTo, mode os.FileMode) error

Types

type ErrorOnce

type ErrorOnce struct {
	// contains filtered or unexported fields
}

func (*ErrorOnce) Error

func (i *ErrorOnce) Error(f func() error) error

type EscapeError

type EscapeError string

func (EscapeError) Error

func (e EscapeError) Error() string

type Fingerprint

type Fingerprint []byte

func (Fingerprint) ToShortName

func (f Fingerprint) ToShortName() string

type LimitedWriter

type LimitedWriter struct {
	W io.Writer // underlying writer
	N int64     // max bytes remaining
}

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (n int, err error)

type RawMessage

type RawMessage []byte

https://code.google.com/p/go/issues/detail?id=6528

func (RawMessage) MarshalJSON

func (m RawMessage) MarshalJSON() ([]byte, error)

func (*RawMessage) UnmarshalJSON

func (m *RawMessage) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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