Documentation ¶
Index ¶
- Constants
- Variables
- func AccountAddressToEthAddr(addr string) (common.Address, error)
- func AccountAddressToHex(addr string) (string, error)
- func FormatJson(msg interface{}) (string, error)
- func FormatMDLink(msg string, link string) string
- func MustAccountAddressToHex(addr string) string
- func MustFormatJson(msg interface{}) string
- type Cache
- type Hash
- type SimpleCache
- func (c *SimpleCache) Get(k string) (interface{}, bool)
- func (c *SimpleCache) GetTo(k string, ret interface{}) error
- func (c *SimpleCache) Remove(k string)
- func (c *SimpleCache) RemoveExpired()
- func (c *SimpleCache) Set(k string, v interface{}, expired time.Duration)
- func (c *SimpleCache) SetDefault(k string, v interface{})
Constants ¶
View Source
const ( InfoType = "Info" ErrorType = "Error" AlertType = "Alert" )
View Source
const HashLength = 32
Variables ¶
View Source
var ZeroHash = [HashLength]byte{0}
Functions ¶
func AccountAddressToEthAddr ¶ added in v0.0.4
AccountAddressToEthAddr parses the given address to an ETH address.
func AccountAddressToHex ¶
func FormatJson ¶
FormatJson returns the json-encoded of the given msg.
func FormatMDLink ¶
FormatMDLink creates a ref-text message following the MarkDown standard.
func MustAccountAddressToHex ¶
MustAccountAddressToHex is the same as AccountAddressToHex except that it will panic upon errors.
func MustFormatJson ¶
func MustFormatJson(msg interface{}) string
MustFormatJson is the same as FormatJson, but it will panic if the given msg cannot be marshalled.
Types ¶
type Cache ¶ added in v0.0.4
type Cache interface { SetDefault(string, interface{}) Set(string, interface{}, time.Duration) Get(string) (interface{}, bool) GetTo(string, interface{}) error Remove(string) RemoveExpired() }
Cache is a simple cache.
type Hash ¶ added in v0.0.4
type Hash [HashLength]byte
func MustNewHashFromString ¶ added in v0.0.4
func NewHashFromString ¶ added in v0.0.4
func RandomHash ¶ added in v0.0.4
func RandomHash() Hash
type SimpleCache ¶ added in v0.0.4
type SimpleCache struct {
*cache.Cache
}
func NewSimpleCache ¶ added in v0.0.4
func NewSimpleCache() *SimpleCache
NewSimpleCache creates a new SimpleCache with default expiration and cleanUpInterval.
func (*SimpleCache) Get ¶ added in v0.0.4
func (c *SimpleCache) Get(k string) (interface{}, bool)
func (*SimpleCache) GetTo ¶ added in v0.0.4
func (c *SimpleCache) GetTo(k string, ret interface{}) error
func (*SimpleCache) Remove ¶ added in v0.0.4
func (c *SimpleCache) Remove(k string)
func (*SimpleCache) RemoveExpired ¶ added in v0.0.4
func (c *SimpleCache) RemoveExpired()
func (*SimpleCache) Set ¶ added in v0.0.4
func (c *SimpleCache) Set(k string, v interface{}, expired time.Duration)
func (*SimpleCache) SetDefault ¶ added in v0.0.4
func (c *SimpleCache) SetDefault(k string, v interface{})
Click to show internal directories.
Click to hide internal directories.