common

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2017 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

Variables

This section is empty.

Functions

func Bytes

func Bytes(s uint64) string

Bytes produces a human readable representation of an SI size.

See also: ParseBytes.

Bytes(82854982) -> 83MB

func ComputeHmac256 added in v0.0.7

func ComputeHmac256() string

func ErrorParse

func ErrorParse(valid validation.Validation) string

func GenUrl

func GenUrl(s string) (url string)

func GenUuid

func GenUuid() (string, error)

func GetFileSize

func GetFileSize(name string) (int64, error)

func GetFullPath

func GetFullPath(name string) string

func GetLinkPath

func GetLinkPath(name string) string

func IBytes

func IBytes(s uint64) string

IBytes produces a human readable representation of an IEC size.

See also: ParseBytes.

IBytes(82854982) -> 79MiB

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes into the number of bytes it represents.

See Also: Bytes, IBytes.

ParseBytes("42MB") -> 42000000, nil ParseBytes("42mib") -> 44040192, nil

func Pwdhash

func Pwdhash(str string) string

password hash function

func RandInt

func RandInt(min int, max int) int

func RandStr

func RandStr(strSize int, randType string) string

func RandomString

func RandomString(l int) string

func StringsToJson

func StringsToJson(str string) string

func Strtomd5

func Strtomd5(s string) string

create md5 string

Types

type Cache

type Cache struct {
	Cachetime int64
	Name      string "maincache"
	Verbose   bool
	// contains filtered or unexported fields
}

func (*Cache) Clear

func (c *Cache) Clear(key interface{}) (*Cache, error)

func (*Cache) ClearAll

func (c *Cache) ClearAll() (*Cache, error)

func (*Cache) ClearGroup

func (c *Cache) ClearGroup(group string) (*Cache, error)

func (*Cache) Delete

func (c *Cache) Delete(key string) *Cache

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) GetKey

func (c *Cache) GetKey(key interface{}) string

func (*Cache) IsExist

func (c *Cache) IsExist(key string) bool

func (*Cache) Put

func (c *Cache) Put(group, key string, val interface{}) (*Cache, error)

type Request

type Request struct {
	Line     string        `json: "line"`
	Device   string        `json: "device"`
	Baud     int           `json: "baud"`
	StopBits int64         `json: "stop_bits"`
	Sleep    int64         `json: "sleep"`
	Timeout  time.Duration `json: "timeout"`
	Command  []byte        `json: "command"`
	Result   bool          `json: "result"`
}

type Result

type Result struct {
	Command   []byte `json: "command"`
	Device    string `json: "device"`
	Result    string `json: "result"`
	Error     string `json: "error"`
	ErrorCode string `json: "error_code"`
}

Directories

Path Synopsis
Package uuid provides implementation of Universally Unique Identifier (UUID).
Package uuid provides implementation of Universally Unique Identifier (UUID).

Jump to

Keyboard shortcuts

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