Documentation ¶
Index ¶
- Constants
- func ConvertMapToStruct(object interface{}, values interface{}) error
- func Encrypt(content string, salt string) string
- func GenerateRandomString() string
- func ParseEndpoint(endpoint string) (*url.URL, error)
- func ParseProjectIDOrName(value interface{}) (int64, string, error)
- func ParseRepository(repository string) (project, rest string)
- func ParseTimeStamp(timestamp string) (*time.Time, error)
- func ReversibleDecrypt(str, key string) (string, error)
- func ReversibleEncrypt(str, key string) (string, error)
- func SafeCastBool(value interface{}) bool
- func SafeCastFloat64(value interface{}) float64
- func SafeCastInt(value interface{}) int
- func SafeCastString(value interface{}) string
- func TestTCPConn(addr string, timeout, interval int) error
- type Link
- type Links
- type TimeMarker
Constants ¶
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 GenerateRandomString ¶
func GenerateRandomString() string
GenerateRandomString generates a random string
func ParseEndpoint ¶
ParseEndpoint parses endpoint to a URL
func ParseProjectIDOrName ¶
ParseProjectIDOrName parses value to ID(int64) or name(string)
func ParseRepository ¶
ParseRepository splits a repository into two parts: project and rest
func ParseTimeStamp ¶
ParseTimeStamp parse timestamp to time
func ReversibleDecrypt ¶
ReversibleDecrypt decrypts the str with aes/base64 or base 64 depending on "header"
func ReversibleEncrypt ¶
ReversibleEncrypt encrypts the str with aes/base64
func SafeCastString ¶
func SafeCastString(value interface{}) string
SafeCastString -- cast a object to string saftely
func TestTCPConn ¶
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 TimeMarker ¶
TimeMarker is used to control an action not to be taken frequently within the interval
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.