common

package
v0.0.0-...-f69eaad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TruncSuffix = iota
	TruncPrefix
	TruncMiddle
)

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

func Base64Encode

func Base64Encode(s string) string

func ConvertSizeToBytes

func ConvertSizeToBytes(size string) int

func CurrentUTCTime

func CurrentUTCTime() string

func EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte

func EnsureDirExist

func EnsureDirExist(name string) error

func FileExists

func FileExists(name string) bool

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GeneratePrivateKey

func GeneratePrivateKey(bitSize int) (*rsa.PrivateKey, error)

func GetValidString

func GetValidString(s string, position int, positive bool) string

func GzipCompressFile

func GzipCompressFile(srcPath, dstPath string) error

func HTTPGMTDate

func HTTPGMTDate() string

func MD5Encode

func MD5Encode(b []byte) string

func MakeSignature

func MakeSignature(key, date string) string

func MakeSureDirExit

func MakeSureDirExit(filePath string)

func Sum

func Sum(i []int) int

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

func WriteKeyToFile

func WriteKeyToFile(keyBytes []byte, saveFileTo string) error

Types

type Client

type Client struct {
	Timeout  time.Duration
	Headers  map[string]string
	Auth     ClientAuth
	BaseHost string

	UrlParsers []UrlParser
	// contains filtered or unexported fields
}

func NewClient

func NewClient(timeout time.Duration, baseHost string) Client

func (*Client) Delete

func (c *Client) Delete(url string, res interface{}, params ...map[string]string) (resp *http.Response, err error)

func (*Client) Do

func (c *Client) Do(method, url string, data, res interface{}, params ...map[string]string) (resp *http.Response, err error)

Do wrapper http.Client Do() for using auth and error handle params:

  1. query string if set {"name": "ibuler"}

func (*Client) Get

func (c *Client) Get(url string, res interface{}, params ...map[string]string) (resp *http.Response, err error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body interface{}, params []map[string]string) (req *http.Request, err error)

func (*Client) Patch

func (c *Client) Patch(url string, data interface{}, res interface{}, params ...map[string]string) (resp *http.Response, err error)

func (*Client) Post

func (c *Client) Post(url string, data interface{}, res interface{}, params ...map[string]string) (resp *http.Response, err error)

func (*Client) PostForm

func (c *Client) PostForm(url string, data interface{}, res interface{}) (err error)

func (*Client) Put

func (c *Client) Put(url string, data interface{}, res interface{}, params ...map[string]string) (resp *http.Response, err error)

func (*Client) SetAuth

func (c *Client) SetAuth(auth ClientAuth)

func (*Client) SetBasicAuth

func (c *Client) SetBasicAuth(username, password string)

func (*Client) SetCookie

func (c *Client) SetCookie(k, v string)

func (*Client) SetHeader

func (c *Client) SetHeader(k, v string)

func (*Client) SetReqHeaders

func (c *Client) SetReqHeaders(req *http.Request, params []map[string]string)

func (*Client) UploadFile

func (c *Client) UploadFile(url string, gFile string, res interface{}, params ...map[string]string) (err error)

type ClientAuth

type ClientAuth interface {
	Sign() (date, sign string)
}

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

func NewPagination

func NewPagination(data []interface{}, size int) *Pagination

func (*Pagination) CurrentPage

func (p *Pagination) CurrentPage() int

func (*Pagination) GetNextPageData

func (p *Pagination) GetNextPageData() []interface{}

func (*Pagination) GetPageData

func (p *Pagination) GetPageData(pageIndex int) []interface{}

func (*Pagination) GetPrevPageData

func (p *Pagination) GetPrevPageData() []interface{}

func (*Pagination) HasNext

func (p *Pagination) HasNext() bool

func (*Pagination) HasPrev

func (p *Pagination) HasPrev() bool

func (*Pagination) PageSize

func (p *Pagination) PageSize() int

func (*Pagination) SetPageSize

func (p *Pagination) SetPageSize(size int)

func (*Pagination) TotalCount

func (p *Pagination) TotalCount() int

func (*Pagination) TotalPage

func (p *Pagination) TotalPage() int

type UrlParser

type UrlParser interface {
	// contains filtered or unexported methods
}

type WrapperTable

type WrapperTable struct {
	Labels      []string
	Fields      []string
	FieldsSize  map[string][3]int // 列宽,列最小宽,列最大宽
	Data        []map[string]string
	TotalSize   int
	TruncPolicy int

	Caption string
	// contains filtered or unexported fields
}

func (*WrapperTable) CalculateColumnsSize

func (t *WrapperTable) CalculateColumnsSize()

func (*WrapperTable) Display

func (t *WrapperTable) Display() string

func (*WrapperTable) Initial

func (t *WrapperTable) Initial()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL