Documentation ¶
Index ¶
- Variables
- func FileExists(path string) bool
- func GrepFile(patten string, filename string) (lines []string, err error)
- func InSliceInt(needle int, stack []int) bool
- func InSliceString(needle string, stack []string) bool
- func LeftPadding(str, pad string, length int) string
- func MustGetTlsConfiguration(privateKeyFile, certificateFile, caFile string) *tls.Config
- func MustLoadCertificates(privateKeyFile, certificateFile, caFile string) (tls.Certificate, *x509.CertPool)
- func NewHTTPReqeust(method, url string, queries, headers map[string]string, body []byte) (*http.Request, error)
- func SearchFile(filename string, paths ...string) (fullpath string, err error)
- func SelfDir() string
- func SelfPath() string
- func Slice(s string) (b []byte)
- func SliceIntDiff(s1 []int, s2 []int) []int
- func SliceIntToString(s []int) []string
- func String(b []byte) (s string)
- func TryCache(c Cache, key string, call Callable) interface{}
- type Cache
- type Callable
- type Error
- type HTTPClient
- type HTTPClientIface
- type JSON
- type Locker
- type Logger
- type RedisLocker
- type Reply
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var (
NoError = NewError(0, "")
)
Functions ¶
func GrepFile ¶
GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read
func InSliceInt ¶
InSliceInt checks if needle is in the stack
func InSliceString ¶ added in v0.1.2
func LeftPadding ¶ added in v0.1.2
func MustGetTlsConfiguration ¶
func MustLoadCertificates ¶
func MustLoadCertificates(privateKeyFile, certificateFile, caFile string) (tls.Certificate, *x509.CertPool)
func NewHTTPReqeust ¶
func NewHTTPReqeust(method, url string, queries, headers map[string]string, body []byte) (*http.Request, error)
NewHTTPReqeust makes a http request
func SearchFile ¶
SearchFile Search a file in paths. this is often used in search config file in /etc ~/
func SliceIntDiff ¶
SliceIntDiff differences s1 against s2
func SliceIntToString ¶
SliceIntToString convert []int to []string
Types ¶
type HTTPClient ¶
type HTTPClient struct { Timeout int // contains filtered or unexported fields }
func NewHTTPClient ¶
func NewHTTPClient(timeout int, client *http.Client) *HTTPClient
func (*HTTPClient) DoParallel ¶ added in v0.1.2
func (hc *HTTPClient) DoParallel(reqs ...*http.Request) []*Response
DoParallel http requests, and get response list. Response could be nil
func (*HTTPClient) GetReadCloser ¶
func (hc *HTTPClient) GetReadCloser(req *http.Request) (io.ReadCloser, string, int, error)
GetReadCloser for downloading file
type HTTPClientIface ¶
type RedisLocker ¶
type RedisLocker struct {
// contains filtered or unexported fields
}
func NewRedisLocker ¶
func NewRedisLocker(cli *redis.Client, expire int) *RedisLocker
func (*RedisLocker) Unlock ¶
func (l *RedisLocker) Unlock(key string) bool
Source Files ¶
Click to show internal directories.
Click to hide internal directories.