lang

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 1 Imported by: 9

Documentation

Index

Constants

View Source
const (
	StrategyIntranet = "IL" // 内网限制
	StrategyWhite    = "WL" // 白名单
	StrategyBlack    = "BL" // 黑名单
)
View Source
const NetworkTcp = Network(Tcp)
View Source
const NetworkUdp = Network(Udp)

Variables

View Source
var DefaultPingTime time.Duration = 10000

Functions

func DefaultValue

func DefaultValue[T any](b bool, val T, def T) T

DefaultValue is a generic function that returns either a value or a default based on a boolean condition It uses Go's generics feature to work with any type T

Parameters:

b: boolean condition to determine which value to return
val: the value to return if b is true
def: the default value to return if b is false

Returns:

T: either val or def based on the boolean condition b

func IsNotNil

func IsNotNil[T comparable](value T) bool

func NilDefault

func NilDefault[T comparable](value T, defaultValue T) T

NilDefault NilDefault[T comparable]

@Description:
@param value
@param defaultValue
@return T

func NumberDefault

func NumberDefault[T Number](value T, defaultValue T) T

NumberDefault NumberDefault[T Number]

@Description: If value not eq 0 return value, if not defaultValue.
@param value
@param defaultValue
@return T

Types

type KeyType

type KeyType string

type Network

type Network string

type Number

type Number interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~float32 | ~float64
}

type PlaceholderType

type PlaceholderType = struct{}
var Placeholder PlaceholderType

type TunnelType

type TunnelType string
const (
	Http  TunnelType = "http"
	Https TunnelType = "https"
	Tcp   TunnelType = "tcp"
	Udp   TunnelType = "udp"
)

Jump to

Keyboard shortcuts

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