lib

package module
Version: v2.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2016 License: MIT Imports: 12 Imported by: 38

README

Golang函数库

源于日常开发中的积累

License ReportCard GoDoc

获取

$ go get -u gopkg.in/LyricTian/lib.v2/...

使用

import "gopkg.in/LyricTian/lib.v2"

MIT License

Copyright (c) 2016 Lyric

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type B

type B []byte

B Provide a []byte conversions

func (B) Buffer

func (b B) Buffer() *bytes.Buffer

Buffer Convert []byte to buffer

func (B) DefaultFloat64

func (b B) DefaultFloat64(defaultVal float64) float64

DefaultFloat64 Convert []byte to float64

func (B) DefaultInt64

func (b B) DefaultInt64(defaultVal int64) int64

DefaultInt64 Convert []byte to int64

func (B) DefaultUint64

func (b B) DefaultUint64(defaultVal uint64) uint64

DefaultUint64 Convert []byte to uint64

func (B) Float64

func (b B) Float64() (float64, error)

Float64 Convert []byte to float64

func (B) Int64

func (b B) Int64() (int64, error)

Int64 Convert []byte to int64

func (B) String

func (b B) String() string

String Convert []byte to string

func (B) Uint64

func (b B) Uint64() (uint64, error)

Uint64 Convert []byte to uint64

type Encryption

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

Encryption Provide some commonly used encryption function

func NewEncryption

func NewEncryption(data []byte) *Encryption

NewEncryption Create a Encryption instance data The encrypted data

func (*Encryption) MD5

func (e *Encryption) MD5() (string, error)

MD5 md5 encryption

func (*Encryption) Sha1 added in v2.2.0

func (e *Encryption) Sha1() (string, error)

Sha1 sha1 encryption

type Interface

type Interface interface {
	// String Convert interface{} to string
	String() string
	// Int64 Convert interface{} to int64
	Int64() (int64, error)
	// DefaultInt64 Convert interface{} to int64
	DefaultInt64(defaultVal int64) int64
	// Uint64 Convert interface{} to uint64
	Uint64() (uint64, error)
	// DefaultUint64 Convert interface{} to uint64
	DefaultUint64(defaultVal uint64) uint64
	// Float64 Convert interface{} to float64
	Float64() (float64, error)
	// DefaultFloat64 Convert interface{} to float64
	DefaultFloat64(defaultVal float64) float64
	// Bool Convert interface{} to bool
	Bool() (bool, error)
	// DefaultBool Convert interface{} to bool
	DefaultBool() bool
}

Interface Provide a interface{} conversions

func T

func T(v interface{}) Interface

T Convert interface{} to Interface

type Random

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

Random provide random code generation

func NewRandom

func NewRandom(l int) *Random

NewRandom create the Random instances l the length of the generated random code

func (*Random) LowerLetter

func (rd *Random) LowerLetter() string

LowerLetter the random code generation only contain lowercase letters

func (*Random) Number

func (rd *Random) Number() string

Number generate random code contains only Numbers

func (*Random) NumberAndLetter

func (rd *Random) NumberAndLetter() string

NumberAndLetter generated contains Numbers and letters (case-insensitive) random code

func (*Random) Source

func (rd *Random) Source(source []byte) string

Source from the specified data source to generate random codes

func (*Random) UpperLetter

func (rd *Random) UpperLetter() string

UpperLetter the random code generation only contains uppercase letters

type S

type S string

S Provide a string conversions

func (S) Bool

func (s S) Bool() (bool, error)

Bool Convert string to bool

func (S) Buffer

func (s S) Buffer() *bytes.Buffer

Buffer Convert string to buffer

func (S) Bytes

func (s S) Bytes() []byte

Bytes Convert string to []byte

func (S) DefaultBool

func (s S) DefaultBool() bool

DefaultBool Convert string to bool

func (S) DefaultFloat32 added in v2.2.1

func (s S) DefaultFloat32(defaultVal float32) float32

DefaultFloat32 Convert string to float32

func (S) DefaultFloat64

func (s S) DefaultFloat64(defaultVal float64) float64

DefaultFloat64 Convert string to float64

func (S) DefaultInt added in v2.2.1

func (s S) DefaultInt(defaultVal int) int

DefaultInt Convert string to int

func (S) DefaultInt64

func (s S) DefaultInt64(defaultVal int64) int64

DefaultInt64 Convert string to int64

func (S) DefaultTime

func (s S) DefaultTime(layout string) time.Time

DefaultTime Convert string to time, If conversion errors,return time.Now()

func (S) DefaultUint64

func (s S) DefaultUint64(defaultVal uint64) uint64

DefaultUint64 Convert string to Uint64

func (S) Float32 added in v2.2.1

func (s S) Float32() (float32, error)

Float32 Convert string to float32

func (S) Float64

func (s S) Float64() (float64, error)

Float64 Convert string to float64

func (S) Int added in v2.2.1

func (s S) Int() (int, error)

Int Convert string to int

func (S) Int64

func (s S) Int64() (int64, error)

Int64 Convert string to int64

func (S) String

func (s S) String() string

String Convert S to string

func (S) Time

func (s S) Time(layout string) (time.Time, error)

Time Convert string to time

func (S) Uint64

func (s S) Uint64() (uint64, error)

Uint64 Convert string to uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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