util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bool boolType

Functions

func BoolToUint32

func BoolToUint32(b bool) (i uint32, err error)

bool 2 uint32

func CamelCase

func CamelCase(s string) string

CameCase

func Get

func Get(ctx context.Context, url string, result interface{}, opts ...Option) error

Get

func Int32ToByteArr

func Int32ToByteArr(i int32) (bytes []byte, err error)

int32 2 []byte]

func Int64ToByteArr

func Int64ToByteArr(i int64) (bytes []byte, err error)

int64 to []byte]

func Int64ToStr

func Int64ToStr(i int64) (s string, err error)

int64 2 str

func Int64ToTimestamp

func Int64ToTimestamp(i int64) (string, error)

int64 2 timestamp

func Lcfirst

func Lcfirst(str string) string

func Post

func Post(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error

Post

func Snake

func Snake(s string) string

Snake

func StrToBool

func StrToBool(str string) (b bool, err error)

str 2 bool

func StrToInt

func StrToInt(s string) (i int, err error)

str 2 int

func StrToInt32

func StrToInt32(s string) (i int32, err error)

str 2 int32

func StrToInt64

func StrToInt64(s string) (i int64, err error)

str 2 int64

func StrToUin32

func StrToUin32(s string) (i uint32, err error)

str 2 uint32

func StrToUin64

func StrToUin64(s string) (i uint64, err error)

str 2 uint64

func Ucfirst

func Ucfirst(str string) string

func Uint32ToBool

func Uint32ToBool(i uint32) (b bool, err error)

uint32 2 bool

func Uint32ToByteArr

func Uint32ToByteArr(i uint32) (bytes []byte, err error)

uint32 2 []byte]

func Uint32ToStr

func Uint32ToStr(i uint32) (s string, err error)

uint32 2 string

func Uint64ToByteArr

func Uint64ToByteArr(i uint64) (bytes []byte, err error)

uint64 to []byte

func Uint64ToStr

func Uint64ToStr(i uint64) (s string, err error)

uint64 to str

func WhoCalling

func WhoCalling() string

获取调用的方法名

func WrapRecover

func WrapRecover(f func() error) error

Types

type IHttp

type IHttp interface {
	// get
	Get(ctx context.Context, url string, result interface{}, opts ...Option) error
	// post
	Post(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error
}

func NewHttp

func NewHttp() IHttp

type Method

type Method string
const (
	HttpTimeOut        = 10 * time.Second
	HttpPost    Method = "POST"
	HttpGet     Method = "GET"
)

type Option

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

func WithHeader

func WithHeader(headers map[string]string) Option

func WithMethod

func WithMethod(method Method) Option

func WithParam

func WithParam(params map[string]interface{}) Option

func WithPreDeal

func WithPreDeal(preDeal func(r *Parameter) error) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Parameter

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

参数

func (*Parameter) SetBody

func (p *Parameter) SetBody(body io.Reader)

type RawBytes

type RawBytes []byte

RawBytes is a byte slice that holds a reference to memory owned by the database itself. After a Scan into a RawBytes, the slice is only valid until the next call to Next, Scan, or Close.

type Scanner

type Scanner interface {
	// Scan assigns a value from a database driver.
	//
	// The src value will be of one of the following types:
	//
	//    int64
	//    float64
	//    bool
	//    []byte
	//    string
	//    time.Time
	//    nil - for NULL values
	//
	// An error should be returned if the value cannot be stored
	// without loss of information.
	//
	// Reference types such as []byte are only valid until the next call to Scan
	// and should not be retained. Their underlying memory is owned by the driver.
	// If retention is necessary, copy their values before the next call to Scan.
	Scan(src interface{}) error
}

type Value

type Value interface{}

Value is a value that drivers must be able to handle. It is either nil, a type handled by a database driver's NamedValueChecker interface, or an instance of one of these types:

int64
float64
bool
[]byte
string
time.Time

Jump to

Keyboard shortcuts

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