types

package
v0.0.0-...-d6cb8d1 Latest Latest
Warning

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

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

Documentation

Overview

Package types provides various common types.

Index

Examples

Constants

This section is empty.

Variables

EmptyBody is a ReadCloser that returns EOF on Read and does nothing on Close.

NopCloser is an io.Closer that does nothing.

Functions

func NewFakeSeeker

func NewFakeSeeker(r io.Reader, size int64) io.ReadSeeker

NewFakeSeeker returns a ReadSeeker that can pretend to Seek (based on the provided total size of the reader's content), but any reads will fail if the fake seek position doesn't match reality.

func NewOnceCloser

func NewOnceCloser(c io.Closer) io.Closer

NewOnceCloser returns a Closer wrapping c which only calls Close on c once. Subsequent calls to Close return nil.

func NewStatsReadSeeker

func NewStatsReadSeeker(v *expvar.Int, r io.ReadSeeker) io.ReadSeeker

NewReaderStats returns an io.ReadSeeker that will have the number of bytes read from rs added to v.

func NewStatsReader

func NewStatsReader(v *expvar.Int, r io.Reader) io.Reader

NewReaderStats returns an io.Reader that will have the number of bytes read from r added to v.

Example
var (
	// r is the io.Reader we'd like to count read from.
	r  = strings.NewReader("Hello world")
	v  = expvar.NewInt("read-bytes")
	sw = NewStatsReader(v, r)
)
// Read from the wrapped io.Reader, StatReader will count the bytes.
io.Copy(ioutil.Discard, sw)
fmt.Printf("Read %s bytes\n", v.String())
Output:

Read 11 bytes

func U32

func U32(n int64) uint32

U32 converts n to an uint32, or panics if n is out of range

Types

type AtomicBool

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

AtomicBool is an atomic boolean. It can be accessed from concurrent goroutines.

func (*AtomicBool) Get

func (b *AtomicBool) Get() bool

func (*AtomicBool) Set

func (b *AtomicBool) Set(v bool)

type AtomicInt64

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

func (*AtomicInt64) Add

func (a *AtomicInt64) Add(delta int64) int64

func (*AtomicInt64) Get

func (a *AtomicInt64) Get() int64

func (*AtomicInt64) Set

func (a *AtomicInt64) Set(v int64)

type ByTime

type ByTime []time.Time

ByTime sorts times.

func (ByTime) Len

func (s ByTime) Len() int

func (ByTime) Less

func (s ByTime) Less(i, j int) bool

func (ByTime) Swap

func (s ByTime) Swap(i, j int)

type CloseFunc

type CloseFunc func() error

CloseFunc implements io.Closer with a function.

func (CloseFunc) Close

func (fn CloseFunc) Close() error

type InvertedBool

type InvertedBool bool

InvertedBool is a bool that marshals to and from JSON with the opposite of its in-memory value.

func (InvertedBool) Get

func (ib InvertedBool) Get() bool

Get returns the logical value of ib.

func (InvertedBool) MarshalJSON

func (ib InvertedBool) MarshalJSON() ([]byte, error)

func (*InvertedBool) UnmarshalJSON

func (ib *InvertedBool) UnmarshalJSON(b []byte) error

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

A ReadSeekCloser can Read, Seek, and Close.

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

type SizeReaderAt

type SizeReaderAt interface {
	io.ReaderAt
	Size() int64
}

type TB

type TB interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Skip(args ...interface{})
	SkipNow()
	Skipf(format string, args ...interface{})
	Skipped() bool
}

TB is a copy of testing.TB so things can take a TB without linking in the testing package (which defines its own flags, etc).

type Time3339

type Time3339 time.Time

Time3339 is a time.Time which encodes to and from JSON as an RFC 3339 time in UTC.

func ParseTime3339OrNil

func ParseTime3339OrNil(v string) *Time3339

func ParseTime3339OrZero

func ParseTime3339OrZero(v string) Time3339

ParseTime3339OrZero parses a string in RFC3339 format. If it's invalid, the zero time value is returned instead.

func (*Time3339) IsZero

func (t *Time3339) IsZero() bool

IsZero returns whether the time is Go zero or Unix zero.

func (Time3339) MarshalJSON

func (t Time3339) MarshalJSON() ([]byte, error)

func (Time3339) String

func (t Time3339) String() string

func (Time3339) Time

func (t Time3339) Time() time.Time

Time returns the time as a time.Time with slightly less stutter than a manual conversion.

func (*Time3339) UnmarshalJSON

func (t *Time3339) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
Package camtypes is like the types package, but higher-level and contains Camlistore-specific types.
Package camtypes is like the types package, but higher-level and contains Camlistore-specific types.
Package clientconfig provides types related to the client configuration file.
Package clientconfig provides types related to the client configuration file.
Package serverconfig provides types related to the server configuration file.
Package serverconfig provides types related to the server configuration file.

Jump to

Keyboard shortcuts

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