Documentation ¶
Index ¶
- Constants
- Variables
- func CheckError(err error, errType string)
- func CheckMathod(r *http.Request, method string)
- func CheckSsdbError(resp []string, err error)
- func CheckSsdbErrorDesc(resp []string, err error, desc string)
- func DecodeRequestBody(r *http.Request, v interface{}) error
- func EndTx(tx *sql.Tx, err *error)
- func GenUUID() string
- func GetKv(key string, out interface{}, rc redis.Conn) (exist bool, err error)
- func GetKvDb(key string, out interface{}) (exist bool, err error)
- func GetRedisTime() time.Time
- func GetRedisTimeUnix() int64
- func GetStructFieldKVs(data interface{}) ([]string, []interface{}, error)
- func GetStructFieldKeys(data interface{}) ([]string, error)
- func GetStructFieldValues(data interface{}) ([]interface{}, error)
- func HGetKvs(hkvs []Hkv) error
- func HSetKvs(hkvs []Hkv) error
- func HttpTest(handler ReqHandler, w http.ResponseWriter, req *http.Request)
- func KvDelDb(keys ...interface{}) error
- func KvGet(keys ...interface{}) ([][]byte, error)
- func KvGetDb(keys ...interface{}) ([][]byte, error)
- func KvPut(kvs ...Kv) error
- func KvPutDb(kvs ...Kv) error
- func KvScan(in [][]byte, out ...interface{}) error
- func KvStart(pool *redis.Pool) error
- func LoadCsvArray(file string, slicePtr interface{}) (err error)
- func LoadCsvMap(file string, keyCols []string, mapPtr interface{}) (err error)
- func LoginAuth(username, password, host string) smtp.Auth
- func Max(a, b int64) int64
- func Min(a, b int64) int64
- func NewErr(err error) error
- func NewErrStr(err string) error
- func PanicIfError(err error)
- func PlainAuth(identity, username, password, host string) smtp.Auth
- func RepeatSingletonTask(redisPool *redis.Pool, key string, f func() error)
- func SendError(errType, errStr string)
- func SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) error
- func SetKv(key string, value interface{}, rc redis.Conn) error
- func SetKvDb(key string, value interface{}) error
- func Sha224(s string) string
- func Sha256(s string) string
- func StartKV(db *DB, pool *redis.Pool)
- func Truncate(v, min, max int64) int64
- func WriteResponse(w http.ResponseWriter, v interface{})
- type Client
- func (c *Client) Auth(a smtp.Auth) error
- func (c *Client) Data() (io.WriteCloser, error)
- func (c *Client) Extension(ext string) (bool, string)
- func (c *Client) Mail(from string) error
- func (c *Client) Quit() error
- func (c *Client) Rcpt(to string) error
- func (c *Client) Reset() error
- func (c *Client) StartTLS(config *tls.Config) error
- func (c *Client) Verify(addr string) error
- type DB
- type Err
- type Hkv
- type Kv
- type ReqHandler
Constants ¶
const ( CACHE_LIFE_SEC = 3600 SCRIPT_SET_KV = ` redis.call('set', 'kv/'..KEYS[1], KEYS[2]) redis.call('zadd', 'kvz', KEYS[3], 'kv/'..KEYS[1]) ` SCRIPT_GET_EXPIRED_KV = `` /* 237-byte string literal not displayed */ SCRIPT_GETDEL = `` /* 164-byte string literal not displayed */ )
Variables ¶
var ( HttpCodeInternalServerError = http.StatusInternalServerError HttpCodeBadRequest = http.StatusBadRequest DbMap = make(map[string]*DB) )
var AccessControlAllowOrigins map[string]bool = map[string]bool{}
Functions ¶
func CheckError ¶
func CheckMathod ¶
func CheckSsdbError ¶
func CheckSsdbErrorDesc ¶
func DecodeRequestBody ¶
func GetRedisTime ¶
func GetRedisTimeUnix ¶
func GetRedisTimeUnix() int64
func GetStructFieldKVs ¶
func GetStructFieldKeys ¶
func GetStructFieldValues ¶
func GetStructFieldValues(data interface{}) ([]interface{}, error)
func HttpTest ¶
func HttpTest(handler ReqHandler, w http.ResponseWriter, req *http.Request)
func LoadCsvArray ¶
func LoadCsvMap ¶
use "key1,key2" for multi column key mapPtr must be *map[string]struct
func PanicIfError ¶
func PanicIfError(err error)
func RepeatSingletonTask ¶
use go keyword to start a goroutine
func SendMail ¶
SendMail connects to the server at addr, switches to TLS if possible, authenticates with mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, v interface{})
Types ¶
type Client ¶
type Client struct { // Text is the textproto.Conn used by the Client. It is exported to allow for // clients to add extensions. Text *textproto.Conn // contains filtered or unexported fields }
func NewClient ¶
NewClient returns a new Client using an existing connection and host as a server name to be used when authenticating.
func (*Client) Auth ¶
Auth authenticates a client using the provided authentication mechanism. A failed authentication closes the connection. Only servers that advertise the AUTH extension support this function.
func (*Client) Data ¶
func (c *Client) Data() (io.WriteCloser, error)
Data issues a DATA command to the server and returns a writer that can be used to write the data. The caller should close the writer before calling any more methods on c. A call to Data must be preceded by one or more calls to Rcpt.
func (*Client) Extension ¶
Extension reports whether an extension is support by the server. The extension name is case-insensitive. If the extension is supported, Extension also returns a string that contains any parameters the server specifies for the extension.
func (*Client) Mail ¶
Mail issues a MAIL command to the server using the provided email address. If the server supports the 8BITMIME extension, Mail adds the BODY=8BITMIME parameter. This initiates a mail transaction and is followed by one or more Rcpt calls.
func (*Client) Rcpt ¶
Rcpt issues a RCPT command to the server using the provided email address. A call to Rcpt must be preceded by a call to Mail and may be followed by a Data call or another Rcpt call.
func (*Client) Reset ¶
Reset sends the RSET command to the server, aborting the current mail transaction.
func (*Client) StartTLS ¶
StartTLS sends the STARTTLS command and encrypts all further communication. Only servers that advertise the STARTTLS extension support this function.
type ReqHandler ¶
type ReqHandler func(http.ResponseWriter, *http.Request)
func (ReqHandler) ServeHTTP ¶
func (fn ReqHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)