gutils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gutils Author: hyphen Copyright 2023 hyphen. All rights reserved. Create-time: 2023/12/4

Package gutils Create-time: 2024/12/24

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastAssert

func FastAssert[T any](v any) T

func MustDo

func MustDo[K, V any](key K, fc func(K) (V, error)) V

func MustDoCtx

func MustDoCtx[K, V any](ctx context.Context, key K, fc func(context.Context, K) (V, error)) V

func MustEasyDo

func MustEasyDo[V any](fc func() (V, error)) V

func NoError added in v0.3.0

func NoError[T any](t T) (T, error)

func Paging

func Paging[T any](arr []T, offset, limit int) []T

func TernaryForm

func TernaryForm[T any](cond bool, tureVal, falseVal T) T

Types

type Pair

type Pair[F, S any] struct {
	First  F
	Second S
}

func MakePair

func MakePair[F, S any](f F, s S) *Pair[F, S]

func (*Pair[F, S]) Split

func (p *Pair[F, S]) Split() (F, S)

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]) Close

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

func (*SafeChan[T]) Listen

func (s *SafeChan[T]) Listen() (t T)

func (*SafeChan[T]) Send

func (s *SafeChan[T]) Send(t T)

type SliceSet added in v0.3.0

type SliceSet[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSliceSet added in v0.3.0

func NewSliceSet[K comparable, V any]() *SliceSet[K, V]

func NewSliceSetFormSlice added in v0.3.0

func NewSliceSetFormSlice[K comparable](ss ...[]K) *SliceSet[K, K]

func (*SliceSet[K, V]) Get added in v0.3.0

func (s *SliceSet[K, V]) Get(key K) (V, bool)

func (*SliceSet[K, V]) GetMap added in v0.3.0

func (s *SliceSet[K, V]) GetMap() map[K]int

func (*SliceSet[K, V]) GetSlice added in v0.3.0

func (s *SliceSet[K, V]) GetSlice() []V

func (*SliceSet[K, V]) Insert added in v0.3.0

func (s *SliceSet[K, V]) Insert(key K, value V) bool

func (*SliceSet[K, V]) Update added in v0.3.0

func (s *SliceSet[K, V]) Update(key K, value V) bool

func (*SliceSet[K, V]) Upsert added in v0.3.0

func (s *SliceSet[K, V]) Upsert(key K, value V)

Jump to

Keyboard shortcuts

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