utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Prefix   = "netdoop"
	MaxProcs = 1

	VerboseMode = false
	DebugMode   = false
	ConfigFile  = ""

	WorkDir           = "/opt/netdoop"
	DataPath          = "data"
	ConfPath          = "conf"
	DefaultConfigFile = WorkDir + "/" + ConfPath + "/netdoop.yaml"
)

Functions

func CastRefelectValue

func CastRefelectValue(value string, targetType reflect.Type) reflect.Value

func GenerateRandomString

func GenerateRandomString(length int) string

func GetColorer

func GetColorer() *color.Color

func GetEnv

func GetEnv() *viper.Viper

func GetLogger

func GetLogger() *zap.Logger

func GetRawType

func GetRawType(source interface{}) reflect.Type

func GetRawTypeName

func GetRawTypeName(source interface{}) string

func GetRawTypeShortName

func GetRawTypeShortName(source interface{}) string

func GetRegexp

func GetRegexp(pattern string) *regexp.Regexp

func IsLANAddress

func IsLANAddress(host string) bool

func MergeSlices

func MergeSlices[T comparable](slices ...[]T) []T

func ReadParamList

func ReadParamList(data map[string]string, obj any) error

Types

type BaseTimingServer

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

func (*BaseTimingServer) Run

func (s *BaseTimingServer) Run()

func (*BaseTimingServer) StartTimer

func (s *BaseTimingServer) StartTimer(key string, d time.Duration, f func())

func (*BaseTimingServer) Stop

func (s *BaseTimingServer) Stop()

func (*BaseTimingServer) StopTimer

func (s *BaseTimingServer) StopTimer(key string)

type TimingServer

type TimingServer interface {
	Run()
	Stop()
	StartTimer(key string, d time.Duration, f func())
	StopTimer(key string)
}

func GetTimingServer

func GetTimingServer() TimingServer

func NewBaseTimingServer

func NewBaseTimingServer(tick time.Duration, size int64) (TimingServer, error)

Jump to

Keyboard shortcuts

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