utils

package
v1.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: Apache-2.0 Imports: 19 Imported by: 670

Documentation

Index

Constants

View Source
const (
	// EncryptHeaderV1 ...
	EncryptHeaderV1 = "<enc-v1>"
)

Variables

This section is empty.

Functions

func ConvertMapToStruct

func ConvertMapToStruct(object interface{}, values interface{}) error

ConvertMapToStruct is used to fill the specified struct with map.

func Encrypt

func Encrypt(content string, salt string) string

Encrypt encrypts the content with salt

func GenerateRandomString

func GenerateRandomString() string

GenerateRandomString generates a random string

func ParseEndpoint

func ParseEndpoint(endpoint string) (*url.URL, error)

ParseEndpoint parses endpoint to a URL

func ParseOfftime added in v1.6.0

func ParseOfftime(offtime int64) (hour, minite, second int)

ParseOfftime ...

func ParseProjectIDOrName

func ParseProjectIDOrName(value interface{}) (int64, string, error)

ParseProjectIDOrName parses value to ID(int64) or name(string)

func ParseRepository

func ParseRepository(repository string) (project, rest string)

ParseRepository splits a repository into two parts: project and rest

func ParseTimeStamp

func ParseTimeStamp(timestamp string) (*time.Time, error)

ParseTimeStamp parse timestamp to time

func ReversibleDecrypt

func ReversibleDecrypt(str, key string) (string, error)

ReversibleDecrypt decrypts the str with aes/base64 or base 64 depending on "header"

func ReversibleEncrypt

func ReversibleEncrypt(str, key string) (string, error)

ReversibleEncrypt encrypts the str with aes/base64

func SafeCastBool added in v1.5.2

func SafeCastBool(value interface{}) bool

SafeCastBool --

func SafeCastFloat64 added in v1.5.2

func SafeCastFloat64(value interface{}) float64

SafeCastFloat64 --

func SafeCastInt added in v1.5.2

func SafeCastInt(value interface{}) int

SafeCastInt --

func SafeCastString added in v1.5.2

func SafeCastString(value interface{}) string

SafeCastString -- cast a object to string saftely

func TestTCPConn

func TestTCPConn(addr string, timeout, interval int) error

TestTCPConn tests TCP connection timeout: the total time before returning if something is wrong with the connection, in second interval: the interval time for retring after failure, in second

Types

type Link struct {
	// URL : url part of header
	URL string
	// Rel : prev or next
	Rel string
}

Link : HTTP link header

type Links []*Link

Links : multiple link

func ParseLink(raw string) Links

ParseLink parses the raw link header to Links

func (Links) Next

func (l Links) Next() string

Next returns the URL indicated by "next" rel.

func (Links) Prev

func (l Links) Prev() string

Prev returns the URL indicated by "prev" rel.

type TimeMarker

type TimeMarker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TimeMarker is used to control an action not to be taken frequently within the interval

func ScanAllMarker

func ScanAllMarker() *TimeMarker

ScanAllMarker ...

func ScanOverviewMarker

func ScanOverviewMarker() *TimeMarker

ScanOverviewMarker ...

func (*TimeMarker) Check

func (t *TimeMarker) Check() bool

Check returns true if the current time is after the mark by this marker, and the caction the mark guards and be taken.

func (*TimeMarker) Mark

func (t *TimeMarker) Mark()

Mark tries to mark a future time, which is after the duration of interval from the time it's called.

func (*TimeMarker) Next

func (t *TimeMarker) Next() time.Time

Next returns the time of the next mark.

Directories

Path Synopsis
uaa

Jump to

Keyboard shortcuts

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