utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufGet

func BufGet() *bytes.Buffer

BufGet 获取buf

func BufPut

func BufPut(buf *bytes.Buffer)

BufPut 放置buf

func CreateLogPath

func CreateLogPath(root, appName string) string

CreateLogPath Build log file path

func DelSpace

func DelSpace(args string) []string

func ExternalIP

func ExternalIP() (net.IP, error)

func GetCurPath

func GetCurPath() (string, error)

func SaveFile

func SaveFile(file *multipart.FileHeader, dst string) (string, error)

func WithCap

func WithCap(capNum int) *connPoolWithCap

func WithTimeOut

func WithTimeOut(t time.Duration) *connPoolWithTimeOut

Types

type Conn

type Conn interface {
	Close() error
	Ping() error
}

只要类型实现了Conn接口中的方法,就认为是一个连接资源类型

type ConnPool

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

连接池

func NewConnPool

func NewConnPool(factory Factory, opts ...ConnPoolOption) *ConnPool

创建一个连接资源池

func (*ConnPool) Close

func (cp *ConnPool) Close()

关闭连接池

func (*ConnPool) Get

func (cp *ConnPool) Get() Conn

获取连接资源

func (*ConnPool) Put

func (cp *ConnPool) Put(conn Conn)

连接资源放回池中

type ConnPoolOption

type ConnPoolOption interface {
	Apply(*ConnPool)
}

线程的配置

type ConnWithTime

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

连接

type Factory

type Factory func() (Conn, error)

工厂方法,用于创建连接资源

Jump to

Keyboard shortcuts

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