utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToStringUnsafe

func BytesToStringUnsafe(b []byte) string

from mosdns(https://github.com/IrineSistiana/mosdns), thank for @IrineSistiana BytesToStringUnsafe converts bytes to string.

func Compare

func Compare[T comparable](old, new []T) ([]T, []T)

func FakeSOA

func FakeSOA(name string) *dns.SOA

from mosdns(https://github.com/IrineSistiana/mosdns), thank for @IrineSistiana

func IsContextCancelled

func IsContextCancelled(ctx context.Context) bool

func Join

func Join[T fmt.Stringer](arr []T, seq string) string

func JsonDecode

func JsonDecode(in any, out any) error

func RandomAddrFromPrefix

func RandomAddrFromPrefix(prefix netip.Prefix) netip.Addr

func RandomIDUint16

func RandomIDUint16() uint16

Types

type ChiRouterBuilder

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

func NewChiRouterBuilder

func NewChiRouterBuilder() *ChiRouterBuilder

func (*ChiRouterBuilder) Add

func (c *ChiRouterBuilder) Add(item *ChiRouterBuilderItem)

func (*ChiRouterBuilder) Build

func (c *ChiRouterBuilder) Build() chi.Router

type ChiRouterBuilderItem

type ChiRouterBuilderItem struct {
	Path        string       `json:"-"`
	Methods     []string     `json:"method"`
	Description any          `json:"description"`
	Handler     http.Handler `json:"-"`
}

type Duration

type Duration time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

type GraphNode

type GraphNode[T comparable] struct {
	// contains filtered or unexported fields
}

func NewGraphNode

func NewGraphNode[T comparable](data T) *GraphNode[T]

func (*GraphNode[T]) AddNext

func (n *GraphNode[T]) AddNext(node *GraphNode[T])

func (*GraphNode[T]) AddPrev

func (n *GraphNode[T]) AddPrev(node *GraphNode[T])

func (*GraphNode[T]) Data

func (n *GraphNode[T]) Data() T

func (*GraphNode[T]) HasNext

func (n *GraphNode[T]) HasNext() bool

func (*GraphNode[T]) HasPrev

func (n *GraphNode[T]) HasPrev() bool

func (*GraphNode[T]) Next

func (n *GraphNode[T]) Next() []*GraphNode[T]

func (*GraphNode[T]) NextMap

func (n *GraphNode[T]) NextMap() map[T]*GraphNode[T]

func (*GraphNode[T]) Prev

func (n *GraphNode[T]) Prev() []*GraphNode[T]

func (*GraphNode[T]) PrevMap

func (n *GraphNode[T]) PrevMap() map[T]*GraphNode[T]

func (*GraphNode[T]) RemoveNext

func (n *GraphNode[T]) RemoveNext(node *GraphNode[T])

func (*GraphNode[T]) RemovePrev

func (n *GraphNode[T]) RemovePrev(node *GraphNode[T])

type Limiter

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

func NewLimiter

func NewLimiter(n int) *Limiter

func (*Limiter) Get

func (l *Limiter) Get(ctx context.Context) bool

func (*Limiter) PutBack

func (l *Limiter) PutBack()

type Listable

type Listable[T any] []T

func (*Listable[T]) MarshalJSON

func (l *Listable[T]) MarshalJSON() ([]byte, error)

func (*Listable[T]) MarshalYAML

func (l *Listable[T]) MarshalYAML() (interface{}, error)

func (*Listable[T]) UnmarshalJSON

func (l *Listable[T]) UnmarshalJSON(data []byte) error

func (*Listable[T]) UnmarshalYAML

func (l *Listable[T]) UnmarshalYAML(unmarshal func(interface{}) error) error

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(data T)

type Result

type Result[T any] struct {
	Value T
	Error error
}

type SafeChan

type SafeChan[T any] struct {
	// contains filtered or unexported fields
}

func NewSafeChan

func NewSafeChan[T any](size int) *SafeChan[T]

func (*SafeChan[T]) Clone

func (c *SafeChan[T]) Clone() *SafeChan[T]

func (*SafeChan[T]) Close

func (c *SafeChan[T]) Close()

func (*SafeChan[T]) Counter

func (c *SafeChan[T]) Counter() int

func (*SafeChan[T]) ReceiveChan

func (c *SafeChan[T]) ReceiveChan() <-chan T

func (*SafeChan[T]) SendChan

func (c *SafeChan[T]) SendChan() chan<- T

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack[T any](size int) *Stack[T]

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(v T)

type Task

type Task TaskGroup

func (*Task) Done

func (t *Task) Done()

type TaskGroup

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

func NewTaskGroup

func NewTaskGroup() *TaskGroup

func NewTaskGroupWithContext

func NewTaskGroupWithContext(ctx context.Context) *TaskGroup

func (*TaskGroup) AddTask

func (g *TaskGroup) AddTask() *Task

func (*TaskGroup) Wait

func (g *TaskGroup) Wait() <-chan struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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