utils

package
v0.3.0-alpha-2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionEqual = iota
	VersionGreater
	VersionLess
)
View Source
const (
	UA = `` /* 135-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func CompVersion added in v0.2.4

func CompVersion(v1, v2 string) (int, error)

func Exists

func Exists(name string) bool

func GetPageItems

func GetPageItems[T any](items []T, page, pageSize int) []T

func GetPageItemsRange added in v0.3.0

func GetPageItemsRange(total, page, pageSize int) (start, end int)

func GetUrlExtension added in v0.3.0

func GetUrlExtension(u string) string

func HttpCookieToMap added in v0.3.0

func HttpCookieToMap(c []*http.Cookie) map[string]string

func In

func In[T comparable](items []T, item T) bool

func Index

func Index[T comparable](items []T, item T) int

func IsLocalIP added in v0.3.0

func IsLocalIP(address string) bool

func LIKE added in v0.3.0

func LIKE(s string) string

func MapToHttpCookie added in v0.3.0

func MapToHttpCookie(m map[string]string) []*http.Cookie

func NoRedirectHttpClient added in v0.3.0

func NoRedirectHttpClient() *http.Client

func OptFilePath added in v0.3.0

func OptFilePath(filePath *string)

func ParseURLIsLocalIP added in v0.3.0

func ParseURLIsLocalIP(u string) (bool, error)

func RandBytes

func RandBytes(n int) []byte

func RandString

func RandString(n int) string

func ReadYaml

func ReadYaml(file string, module any) error

func SortUUID added in v0.3.0

func SortUUID() string

func SplitVersion added in v0.2.4

func SplitVersion(v string) ([]int, error)

func WriteYaml

func WriteYaml(file string, module any) error

Types

type Once added in v0.3.0

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

func (*Once) Do added in v0.3.0

func (o *Once) Do(f func())

func (*Once) Done added in v0.3.0

func (o *Once) Done() (doned bool)

func (*Once) Reset added in v0.3.0

func (o *Once) Reset()

type UpgraderConf

type UpgraderConf func(*websocket.Upgrader)

func WithSubprotocols

func WithSubprotocols(Subprotocols []string) UpgraderConf

type WebSocket

type WebSocket struct {
	Heartbeat time.Duration
}

func DefaultWebSocket

func DefaultWebSocket() *WebSocket

func NewWebSocketServer

func NewWebSocketServer(conf ...WebSocketConfig) *WebSocket

func (*WebSocket) NewWebSocketClient

func (ws *WebSocket) NewWebSocketClient(w http.ResponseWriter, r *http.Request, responseHeader http.Header, conf ...UpgraderConf) (*websocket.Conn, error)

func (*WebSocket) Server

func (ws *WebSocket) Server(w http.ResponseWriter, r *http.Request, Subprotocols []string, handler func(c *websocket.Conn) error) error

type WebSocketConfig

type WebSocketConfig func(*WebSocket)

func WithHeartbeatInterval

func WithHeartbeatInterval(d time.Duration) WebSocketConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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