Documentation ¶
Overview ¶
Package dontpanic provides panic-free alternatives to common operations.
Index ¶
- func Close[T any](ch chan T) (err error)
- func Deref[T any](p *T) (_ T, err error)
- func Div[N constraints.Integer | constraints.Float | constraints.Complex](x, y N) (_ N, err error)
- func MakeSlice[E any, S ~[]E](size ...int) (_ S, err error)
- func Mod[N constraints.Integer](x, y N) (_ N, err error)
- func Recover(err *error)
- func Send[T any](ch chan T, v T) (err error)
- func SetMapIndex[K comparable, V any, M ~map[K]V](m M, k K, v V) (err error)
- func SetSliceIndex[E any, S ~[]E](s S, i int, v E) (err error)
- func Slice[E any, S ~[]E](s S, ijk ...int) (_ S, err error)
- func SliceIndex[E any, S ~[]E](s S, i int) (_ E, err error)
- func StringIndex(s string, i int) (_ byte, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Div ¶
func Div[N constraints.Integer | constraints.Float | constraints.Complex](x, y N) (_ N, err error)
Div returns x / y. Returns an error if y is zero.
func MakeSlice ¶
Make invokes make(S, size...). Returns an error if length is negative or larger than capacity.
Supports empty:
MakeSlice()
or length n:
MakeSlice(n)
or length n and capacity m:
MakeSlice(n, m)
func Mod ¶
func Mod[N constraints.Integer](x, y N) (_ N, err error)
Mod returns x % y. Returns an error if y is zero.
func SetMapIndex ¶
func SetMapIndex[K comparable, V any, M ~map[K]V](m M, k K, v V) (err error)
SetMapIndex sets m[k] = v. Returns an error if m is nil.
func SetSliceIndex ¶
SetSliceIndex sets s[i] = v. Returns an error if i is out of range.
func Slice ¶
Slice returns s[i:j:k]. Returns an error if indexes are out of range or too many are specified.
Supports s[:]
Slice(s)
or s[i:]
Slice(s, i)
or s[i:j]
Slice(s, i, j)
or s[i:j:k]
Slice(s, i, j, k)
func SliceIndex ¶
SliceIndex returns s[i]. Returns an error if i is out of range.
Types ¶
This section is empty.