util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 SSEServer

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

func ToMap

func ToMap[T any, K int | string](arr []T, fn func(T) K) map[K]T

切片转 Map

func Unique

func Unique[T IntInterface | string](data []T) []T

切片去重

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 IntInterface

type IntInterface interface {
	uint | uint8 | uint16 | uint32 | uint64 | int | int8 | int16 | int32 | int64
}

type RoundRobin

type RoundRobin struct {
	CurIndex int
	// contains filtered or unexported fields
}

func (*RoundRobin) Index

func (r *RoundRobin) Index(lens int) (index int)

func (*RoundRobin) PickKey

func (r *RoundRobin) PickKey(keys []string) string

Jump to

Keyboard shortcuts

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