Help us shape the future of Go! Take the 2026 Go Developer Survey

helper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 25 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBreaker      = errors.New("Fuse")
	ErrTxHasBegan   = errors.New("<Ormer.Begin> transaction already begin")
	ErrTxDone       = errors.New("<Ormer.Commit/Rollback> transaction not begin")
	ErrMultiRows    = errors.New("<QuerySeter> return multi rows")
	ErrNoRows       = errors.New("<QuerySeter> no row found")
	ErrStmtClosed   = errors.New("<QuerySeter> stmt already closed")
	ErrArgs         = errors.New("<Ormer> args error may be empty")
	ErrNotImplement = errors.New("have not implement")
)

Functions

func InSlice

func InSlice(array interface{}, item interface{}) bool

InSlice 是否在数组内

func Memcpy

func Memcpy(dest interface{}, src interface{}) (err error)

Memcpy

func Name

func Name(obj interface{}) string

func NewMap

func NewMap(dst interface{}) error

NewMap

func NewSlice

func NewSlice(dsc interface{}, len int) error

NewSlice 创建数组

func RuntimePointer

func RuntimePointer() interface{}

func SetRunStack

func SetRunStack(rs runtimeStack)

func SliceDelete

func SliceDelete(arr interface{}, indexArr ...int) error

SliceDelete 删除数组指定下标元素

func SliceSort

func SliceSort(array interface{}, field string, reverse ...bool)

SliceSort 降序

func SliceSortReverse

func SliceSortReverse(array interface{}, field string)

SliceSortReverse 升序

func Testing

func Testing() bool

Types

type HTTPRequest

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

HTTPRequest provides more useful methods for requesting one url than http.Request.

func HttpDelete

func HttpDelete(url string) *HTTPRequest

Delete returns *HTTPRequest DELETE method.

func HttpGet

func HttpGet(url string) *HTTPRequest

Get returns *HTTPRequest with GET method.

func HttpHead

func HttpHead(url string) *HTTPRequest

Head returns *HTTPRequest with HEAD method.

func HttpPost

func HttpPost(url string) *HTTPRequest

Post returns *HTTPRequest with POST method.

func HttpPut

func HttpPut(url string) *HTTPRequest

Put returns *HTTPRequest with PUT method.

func (*HTTPRequest) Body

func (b *HTTPRequest) Body(data interface{}) *HTTPRequest

Body adds request raw body. it supports string and []byte.

func (*HTTPRequest) Bytes

func (b *HTTPRequest) Bytes() ([]byte, error)

Bytes returns the body []byte in response. it calls Response inner.

func (*HTTPRequest) Debug

func (b *HTTPRequest) Debug(isdebug bool) *HTTPRequest

Debug sets show debug or not when executing request.

func (*HTTPRequest) DoRequest

func (b *HTTPRequest) DoRequest() (resp *http.Response, err error)

DoRequest will do the client.Do

func (*HTTPRequest) DumpBody

func (b *HTTPRequest) DumpBody(isdump bool) *HTTPRequest

DumpBody setting whether need to Dump the Body.

func (*HTTPRequest) DumpRequest

func (b *HTTPRequest) DumpRequest() []byte

DumpRequest return the DumpRequest

func (*HTTPRequest) GetRequest

func (b *HTTPRequest) GetRequest() *http.Request

GetRequest return the request object

func (*HTTPRequest) Header

func (b *HTTPRequest) Header(key, value string) *HTTPRequest

Header add header item string in request.

func (*HTTPRequest) JSONBody

func (b *HTTPRequest) JSONBody(obj interface{}) (*HTTPRequest, error)

JSONBody adds request raw body encoding by JSON.

func (*HTTPRequest) Param

func (b *HTTPRequest) Param(key, value string) *HTTPRequest

Param adds query param in to request. params build query string as ?key1=value1&key2=value2...

func (*HTTPRequest) PostFile

func (b *HTTPRequest) PostFile(formname, filename string) *HTTPRequest

PostFile add a post file to the request

func (*HTTPRequest) Response

func (b *HTTPRequest) Response() (*http.Response, error)

Response executes request client gets response mannually.

func (*HTTPRequest) Retries

func (b *HTTPRequest) Retries(times int) *HTTPRequest

Retries sets Retries times. default is 0 means no retried. -1 means retried forever. others means retried times.

func (*HTTPRequest) SetBasicAuth

func (b *HTTPRequest) SetBasicAuth(username, password string) *HTTPRequest

SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.

func (*HTTPRequest) SetCheckRedirect

func (b *HTTPRequest) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *HTTPRequest

SetCheckRedirect specifies the policy for handling redirects.

If CheckRedirect is nil, the Client uses its default policy, which is to stop after 10 consecutive requests.

func (*HTTPRequest) SetCookie

func (b *HTTPRequest) SetCookie(cookie *http.Cookie) *HTTPRequest

SetCookie add cookie into request.

func (*HTTPRequest) SetEnableCookie

func (b *HTTPRequest) SetEnableCookie(enable bool) *HTTPRequest

SetEnableCookie sets enable/disable cookiejar

func (*HTTPRequest) SetHost

func (b *HTTPRequest) SetHost(host string) *HTTPRequest

SetHost set the request host

func (*HTTPRequest) SetProtocolVersion

func (b *HTTPRequest) SetProtocolVersion(vers string) *HTTPRequest

SetProtocolVersion Set the protocol version for incoming requests. Client requests always use HTTP/1.1.

func (*HTTPRequest) SetProxy

func (b *HTTPRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *HTTPRequest

SetProxy set the http proxy example:

func(req *http.Request) (*url.URL, error) {
	u, _ := url.ParseRequestURI("http://127.0.0.1:8118")
	return u, nil
}

func (*HTTPRequest) SetTLSClientConfig

func (b *HTTPRequest) SetTLSClientConfig(config *tls.Config) *HTTPRequest

SetTLSClientConfig sets tls connection configurations if visiting https url.

func (*HTTPRequest) SetTimeout

func (b *HTTPRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *HTTPRequest

SetTimeout sets connect time out and read-write time out for GotreeRequest.

func (*HTTPRequest) SetTransport

func (b *HTTPRequest) SetTransport(transport http.RoundTripper) *HTTPRequest

SetTransport set the setting transport

func (*HTTPRequest) SetUserAgent

func (b *HTTPRequest) SetUserAgent(useragent string) *HTTPRequest

SetUserAgent sets User-Agent header field

func (*HTTPRequest) Setting

func (b *HTTPRequest) Setting(setting _GotreeHTTPSettings) *HTTPRequest

Setting Change request settings

func (*HTTPRequest) String

func (b *HTTPRequest) String() (string, error)

String returns the body string in response. it calls Response inner.

func (*HTTPRequest) ToFile

func (b *HTTPRequest) ToFile(filename string) error

ToFile saves the body data in response to one file. it calls Response inner.

func (*HTTPRequest) ToJSON

func (b *HTTPRequest) ToJSON(v interface{}) error

ToJSON returns the map that marshals from the body bytes as json in response . it calls Response inner.

func (*HTTPRequest) ToXML

func (b *HTTPRequest) ToXML(v interface{}) error

ToXML returns the map that marshals from the body bytes as xml in response . it calls Response inner.

type TaskGroup

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

组合task

func NewGroup

func NewGroup() *TaskGroup

func (*TaskGroup) Add

func (this *TaskGroup) Add(fun func() error)

CallFAddCallFuncunc 同步匿名回调

func (*TaskGroup) Gotree

func (this *TaskGroup) Gotree() *TaskGroup

func (*TaskGroup) Wait

func (this *TaskGroup) Wait(numGoroutine ...int) error

Wait 等待所有任务执行完成

type VoidValue

type VoidValue struct {
	Void byte
}

Jump to

Keyboard shortcuts

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