anvil

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package anvil contains the helper function/struct

Index

Constants

View Source
const (
	// AirmidPackageName is the constant name of airmid package.
	AirmidPackageName = "github.com/anyvoxel/airmid"

	// AirmidPackageVersion is tthe constant version of airmid package.
	AirmidPackageVersion = "v0.1.0"
)

Variables

This section is empty.

Functions

func Must

func Must(err error)

Must panics on non-nil errors.

func SafeRun

func SafeRun(ctx context.Context, cmd func(context.Context))

SafeRun will execute cmd and recover any panic.

Types

type FnOption

type FnOption[T any] struct {
	Fn func(*T)
}

FnOption is an generic function helper for Option.

func (*FnOption[T]) Apply

func (o *FnOption[T]) Apply(opt *T)

Apply will invoke fn on provide option.

type NoCopy

type NoCopy struct{}

NoCopy may be embedded into structs which must not be copied after the first use.

See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock is a no-op used by -copylocks checker from `go vet`.

type Option

type Option[T any] interface {
	// Apply applies this configuration to the given option
	Apply(*T)
}

Option is an generic configuration helper.

func NewFnOption

func NewFnOption[T any](f func(*T)) Option[T]

NewFnOption will instant an Option with f.

type WaitGroupWrapper

type WaitGroupWrapper struct {
	NoCopy
	sync.WaitGroup
}

WaitGroupWrapper is a help struct for sync.WaitGroup.

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(cb func())

Wrap will handle sync.WaitGroup Add and Done.

Directories

Path Synopsis
Package conv provide the helper function to convert data types & string
Package conv provide the helper function to convert data types & string
Package parallel provide helper function to execute parallel task
Package parallel provide helper function to execute parallel task
Package pointer provide the helper function to convert pointer
Package pointer provide the helper function to convert pointer
Package xerrors defines the helpful errors & function
Package xerrors defines the helpful errors & function
Package xreflect provide the helper function with reflect
Package xreflect provide the helper function with reflect
Package xtime provide the helper function to access time
Package xtime provide the helper function to access time

Jump to

Keyboard shortcuts

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