util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToInt

func BoolToInt(value bool) int

func GenFileName

func GenFileName(ext string) string

func GenImageName

func GenImageName(ext string, width, height int) string

随机生成指定后缀的图片名

func GenValidateCode

func GenValidateCode(length int) string

生成数字验证码

func GenerateId

func GenerateId() string

func HttpDownloadFile

func HttpDownloadFile(ctx context.Context, fileURL string, proxyURL ...string) []byte

func HttpGet

func HttpGet(ctx context.Context, url string, header map[string]string, data g.Map, result interface{}, proxyURL ...string) error

func HttpPost

func HttpPost(ctx context.Context, url string, header map[string]string, data, result interface{}, proxyURL ...string) error

func HttpPostJson

func HttpPostJson(ctx context.Context, url string, header map[string]string, data, result interface{}, proxyURL ...string) error

func NewMsgId

func NewMsgId() string

func NewSecretKey

func NewSecretKey(userId, length int, prefix ...string) string

func Random

func Random(length int) string

生成随机字符串

func SSEServer

func SSEServer(ctx context.Context, event string, content any) error

func WebSocketClient

func WebSocketClient(ctx context.Context, wsURL string, messageType int, message []byte, result chan []byte, proxyURL ...string) (*websocket.Conn, error)

func WebSocketClientOnlyReceive

func WebSocketClientOnlyReceive(ctx context.Context, wsURL string, result chan []byte, proxyURL ...string) (*websocket.Conn, error)

Types

type RoundRobin

type RoundRobin struct {
	CurIndex int
}

func (*RoundRobin) RoundRobin

func (roundRobin *RoundRobin) RoundRobin(values []string) (value string)

轮询模式

Jump to

Keyboard shortcuts

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