helper

package module
v0.0.0-...-07743a7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2015 License: MIT Imports: 14 Imported by: 0

README

helper

helper

Documentation

Overview

The uuid package can be used to generate and parse universally unique identifiers, a standardized format in the form of a 128 bit number.

http://tools.ietf.org/html/rfc4122

Index

Constants

View Source
const (
	VariantNCSCompat = 0
	VariantIETF      = 2
	VariantMicrosoft = 6
	VariantFuture    = 7
)

Variables

This section is empty.

Functions

func DayOfYear

func DayOfYear(year, month, day int) int

计算该天属于该年的第几天

func MapToUrlValues

func MapToUrlValues(data map[string]interface{}) (url.Values, error)

func Segmenter

func Segmenter(segmenter sego.Segmenter, key string) []string

func StrLen

func StrLen(str string) int

func StrToTimestamp

func StrToTimestamp(stime string) int64

func SubStr

func SubStr(str string, start, length int) (substr string)

字符串切割,支持中文

func TimestampToStr

func TimestampToStr(timestamp int64) string

Types

type AutoInc

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

func NewAutoInc

func NewAutoInc(start, step int) (ai *AutoInc)

func (*AutoInc) Close

func (ai *AutoInc) Close()

func (*AutoInc) Id

func (ai *AutoInc) Id() int

type Mongo

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

func NewMongo

func NewMongo(dns, mode string, refresh bool) *Mongo

func (*Mongo) C

func (m *Mongo) C(collection bson.M) *mgo.Collection

func (*Mongo) Close

func (m *Mongo) Close()

type UUID

type UUID [16]byte

func ParseUUID

func ParseUUID(input string) (UUID, error)

ParseUUID parses a 32 digit hexadecimal number (that might contain hypens) represanting an UUID.

func RandomUUID

func RandomUUID() (UUID, error)

RandomUUID generates a totally random UUID (version 4) as described in RFC 4122.

func TimeUUID

func TimeUUID() UUID

TimeUUID generates a new time based UUID (version 1) using the current time as the timestamp.

func UUIDFromBytes

func UUIDFromBytes(input []byte) (UUID, error)

UUIDFromBytes converts a raw byte slice to an UUID.

func UUIDFromTime

func UUIDFromTime(aTime time.Time) UUID

UUIDFromTime generates a new time based UUID (version 1) as described in RFC 4122. This UUID contains the MAC address of the node that generated the UUID, the given timestamp and a sequence number.

func (UUID) Bytes

func (u UUID) Bytes() []byte

Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits (16 bytes) long.

func (UUID) Node

func (u UUID) Node() []byte

Node extracts the MAC address of the node who generated this UUID. It will return nil if the UUID is not a time based UUID (version 1).

func (UUID) String

func (u UUID) String() string

String returns the UUID in it's canonical form, a 32 digit hexadecimal number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (UUID) Time

func (u UUID) Time() time.Time

Time is like Timestamp, except that it returns a time.Time.

func (UUID) Timestamp

func (u UUID) Timestamp() int64

Timestamp extracts the timestamp information from a time based UUID (version 1).

func (UUID) Variant

func (u UUID) Variant() int

Variant returns the variant of this UUID. This package will only generate UUIDs in the IETF variant.

func (UUID) Version

func (u UUID) Version() int

Version extracts the version of this UUID variant. The RFC 4122 describes five kinds of UUIDs.

Jump to

Keyboard shortcuts

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