Documentation ¶
Index ¶
- Constants
- Variables
- func CmpPasswd(passwd, salt, encrypted string) bool
- func Convert(dst interface{}, val interface{}) error
- func Crc16(bs []byte) (crc uint16)
- func FileExist(path string) bool
- func FileSize(file string) (int64, error)
- func GenHmacSha256(plaintext string, saltlen int) string
- func GenPasswd(password string, saltlen int) (string, string)
- func GetProcPwd() string
- func IfEmpty(a, b string) string
- func IsChinese(str string) bool
- func IsChineseLetterNumUnline(str string) bool
- func IsDigit(str string) bool
- func IsDir(dir string) bool
- func IsEmail(str string) bool
- func IsEmailRFC(str string) bool
- func IsFile(filePath string) bool
- func IsLetterNumUnline(str string) bool
- func IsSliceContainsInt64(sl []int64, i int64) bool
- func IsSliceContainsStr(sl []string, str string) bool
- func IsURL(str string) bool
- func Kermit(byteArray []byte) uint16
- func KermitStr(input string) string
- func Map2Field(vals map[string]interface{}, dst interface{}, tag string) error
- func Map2Struct(vals map[string]interface{}, dst interface{}) (err error)
- func Map2StructTag(vals map[string]interface{}, dst interface{}, tagName string) (err error)
- func NewRand(len int) string
- func NewRandWithPrefix(prefix string, len int) string
- func NewUUID() string
- func NormRand(n int64) float64
- func RangeRand(n int) int
- func SliceInt64To(sts []int64) []interface{}
- func SliceStrTo(sts []string) []interface{}
- func Struct2Map(s interface{}) map[string]interface{}
- func Struct2MapTag(s interface{}, tagName string) map[string]interface{}
- type Attachment
- type Cache
- func (c Cache) Add(k string, x interface{}, d time.Duration) error
- func (c Cache) Clear()
- func (c Cache) Delete(k string)
- func (c Cache) DeleteExpired()
- func (c Cache) Get(k string) (interface{}, bool)
- func (c Cache) ItemCount() int
- func (c Cache) OnEvicted(f func(string, interface{}))
- func (c Cache) Replace(k string, x interface{}, d time.Duration) error
- func (c Cache) Set(k string, x interface{}, d time.Duration)
- func (c Cache) UpdateExpiration(k string, Expiration int64) error
- type Crypto
- type Item
- type Message
- type RefVal
Constants ¶
const ( // For use with functions that take an expiration time. NoExpiration time.Duration = -1 )
Variables ¶
Functions ¶
func Convert ¶
func Convert(dst interface{}, val interface{}) error
Convert varies types of value to a certain type. Value can be type of string or json or whatever type which is convertable to the target type.
func FileExist ¶
checks whether a file or directory exists. It returns false when the file or directory does not exist.
func GenHmacSha256 ¶
generate a hmac sha256 string
func GetProcPwd ¶
func GetProcPwd() string
returns the complete directory of the current execution file
func IsDir ¶
returns true if given path is a directory, or returns false when it's a file or does not exist.
func IsEmailRFC ¶
func IsFile ¶
returns true if given path is a file, or returns false when it's a directory or does not exist.
func IsLetterNumUnline ¶
func IsSliceContainsInt64 ¶
----------------------------------------------------------
func IsSliceContainsStr ¶
----------------------------------------------------------
func Map2Struct ¶
func Map2StructTag ¶
func NewRandWithPrefix ¶
func SliceInt64To ¶
func SliceInt64To(sts []int64) []interface{}
----------------------------------------------------------
func SliceStrTo ¶
func SliceStrTo(sts []string) []interface{}
----------------------------------------------------------
func Struct2Map ¶
func Struct2Map(s interface{}) map[string]interface{}
func Struct2MapTag ¶
Types ¶
type Attachment ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
Return a new cache with a given cleanup interval. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.DeleteExpired().
func (Cache) Add ¶
Add an item to the cache only if an item doesn't already exist for the given key, or if the existing item has expired. Returns an error otherwise.
func (Cache) Delete ¶
func (c Cache) Delete(k string)
Delete an item from the cache. Does nothing if the key is not in the cache.
func (Cache) DeleteExpired ¶
func (c Cache) DeleteExpired()
Delete all expired items from the cache.
func (Cache) Get ¶
Get an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.
func (Cache) ItemCount ¶
func (c Cache) ItemCount() int
Returns the number of items in the cache. This may include items that have expired, but have not yet been cleaned up. Equivalent to len(c.Items()).
func (Cache) OnEvicted ¶
func (c Cache) OnEvicted(f func(string, interface{}))
Sets an (optional) function that is called with the key and value when an item is evicted from the cache. (Including when it is deleted manually, but not when it is overwritten.) Set to nil to disable.
func (Cache) Replace ¶
Set a new value for the cache key only if it already exists, and the existing item hasn't expired. Returns an error otherwise.
func (Cache) Set ¶
Add an item to the cache, replacing any existing item. If it is -1 (NoExpiration), the item never expires.
func (Cache) UpdateExpiration ¶
type Message ¶
type Message struct { From string To []string Cc []string Bcc []string Subject string Body string BodyContentType string Attachments map[string]*Attachment }
func NewHTMLMessage ¶
NewMessage returns a new Message that can compose an HTML email with attachments
func NewMessage ¶
NewMessage returns a new Message that can compose an email with attachments