Documentation ¶
Index ¶
- Constants
- Variables
- func BirthdayToAge(birthday string) (age int)
- func Bytes2String(b []byte) string
- func ClientIP(ip string) string
- func CreateCaptcha(num int) string
- func CurrentFileName() string
- func CurrentMethodName() string
- func DeepCopy(value interface{}) interface{}
- func Difference(slice1, slice2 []int) []int
- func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
- func ExecShell(name string, arg ...string) ([]byte, error)
- func FileIsExist(path string) bool
- func FirstDayOfISOWeek(year int, week int, timezone *time.Location) time.Time
- func GetIPByPconline(ip string) string
- func GetMondayOfWeek(t time.Time, fmtStr string) (dayStr string)
- func GetNextWeekMonday(t time.Time, fmtStr string) (day string, err error)
- func GetTimeRemainSeconds(startTimeStr, endTimeStr string) int
- func GetWeekDay(date string) string
- func GetZeroTime(t time.Time) time.Time
- func InArray(val interface{}, array interface{}) (exists bool, index int)
- func Intersect(slice1 []int, slice2 []int) []int
- func IoCopy(r io.Reader) ([]byte, error)
- func MD5(str string) string
- func Nl2br(str string, isXhtml bool) string
- func NowTime(format ...string) string
- func PublicIP() string
- func RandFloat64(min, max float64, decimalNum int) float64
- func RandIntn(max int) int
- func RemoveDuplicateWithInt(arr []int) []int
- func RemoveDuplicateWithString(arr []string) []string
- func RemoveWithInt(arr []int, in int) []int
- func RemoveWithString(arr []string, in string) []string
- func SafeCloseChan(ch chan interface{}) (closed bool)
- func SafeSendChan(ch chan<- interface{}, value interface{}) (closed bool)
- func SortMapByKey(mp map[string]interface{}) string
- func StrFirstToLower(str string) string
- func StrFirstToUpper(str string) string
- func String2Bytes(s string) []byte
- func Struct2Map(obj interface{}) map[string]interface{}
- func SubString(str string, begin, length int) string
- func SystemIP() string
- func TodayRemainSecond() time.Duration
- type Request
- func (r *Request) Get() (*Response, error)
- func (r *Request) Post() (*Response, error)
- func (r *Request) Send() (*Response, error)
- func (r *Request) SetBody(body io.Reader) *Request
- func (r *Request) SetCookies(cookies map[string]string) *Request
- func (r *Request) SetHeaders(headers map[string]string) *Request
- func (r *Request) SetMethod(method string) *Request
- func (r *Request) SetPostData(postData map[string]interface{}) *Request
- func (r *Request) SetQueries(queries map[string]string) *Request
- func (r *Request) SetTimeOut(timeout time.Duration) *Request
- func (r *Request) SetUrl(url string) *Request
- type Response
Constants ¶
const (
DefaultHttpClientTimeout = 10 * time.Second
)
Variables ¶
var HttpClient = (func() *http.Client { t := http.DefaultTransport.(*http.Transport).Clone() t.MaxIdleConns = 100 t.MaxConnsPerHost = 100 t.MaxIdleConnsPerHost = 100 return &http.Client{Transport: t, Timeout: httpClientTimeout} })()
自定义http.Client,在原来http.DefaultTransport的基础上进行性能优化 @see https://www.loginradius.com/blog/async/tune-the-go-http-client-for-high-performance
Functions ¶
func Bytes2String ¶
Bytes2String ... @author Cloud|2021-12-12 18:24:20 @param b []byte ... @return string ...
func CurrentFileName ¶
func CurrentFileName() string
func CurrentMethodName ¶
func CurrentMethodName() string
func Difference ¶
取要校验的和已经校验过的差集,找出需要校验的切片IP(找出slice1中 slice2中没有的)
func DrainBody ¶
func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
func FirstDayOfISOWeek ¶
通过ISOWeek翻转得到周的日期时间 @see https://blog.csdn.net/pingD/article/details/60964306
func GetIPByPconline ¶
func GetNextWeekMonday ¶
获取上周周日日期
func GetTimeRemainSeconds ¶
获取两个时间的秒数差
func NowTime ¶
NowTime 当前时间 @author Cloud|2021-12-13 09:40:41 @param format ...string ... @return string ...
func RandFloat64 ¶
RandFloat64 区间范围内获取随机数 min 最小值 max float64 最大值 decimalNum int 返回几位小数点
func RemoveDuplicateWithInt ¶
RemoveDuplicateWithInt 去除重复值 @author Cloud|2021-12-12 18:20:52 @param arr []int ... @return []int ...
func RemoveDuplicateWithString ¶
RemoveDuplicateWithString 去除重复值 @author Cloud|2021-12-13 09:33:05 @param arr []string ... @return []string ...
func RemoveWithInt ¶
RemoveWithInt 删除数组中的指定值 @author Cloud|2021-12-14 12:15:15 @param arr []int ... @param in int ... @return []int ...
func RemoveWithString ¶
RemoveWithString 删除数组中的指定值 @author Cloud|2021-12-12 18:20:21 @param arr []string ... @param in string ... @return []string ...
func SafeCloseChan ¶
func SafeCloseChan(ch chan interface{}) (closed bool)
func SafeSendChan ¶
func SafeSendChan(ch chan<- interface{}, value interface{}) (closed bool)
func String2Bytes ¶
String2Bytes ... @author Cloud|2021-12-12 18:24:23 @param s string ... @return []byte ...
func TodayRemainSecond ¶
TodayRemainSecond 获取当天剩余的秒数 @author Cloud|2021-12-12 12:49:41 @return time.Duration ...
Types ¶
type Request ¶
type Request struct { Method string Url string Timeout time.Duration Headers map[string]string Cookies map[string]string Queries map[string]string PostData map[string]interface{} Body io.Reader // contains filtered or unexported fields }
func (*Request) SetCookies ¶
SetCookies
func (*Request) SetHeaders ¶
SetHeaders
func (*Request) SetPostData ¶
SetPostData
func (*Request) SetQueries ¶
设置url查询参数
func (*Request) SetTimeOut ¶
SetTimeOut
type Response ¶
Response 构造类
func NewResponse ¶
func NewResponse() *Response