typez

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 1 Imported by: 5

README

gopherz

ezpkg.io/typez

PkgGoDev GitHub License version

Package typez provides generic functions for working with types.

Installation

go get -u ezpkg.io/typez@v0.2.2

Examples

typez.In(1, 1, 2, 3)    // true
typez.In("A", "B", "C") // false

type A struct{X int}
typez.Coalesce(0, 1, 2, 3) // 1
typez.Coalesce(nil, &A{10}, &A{20}) // &A{10}

About ezpkg.io

As I work on various Go projects, I often find myself creating utility functions, extending existing packages, or developing packages to solve specific problems. Moving from one project to another, I usually have to copy or rewrite these solutions. So I created this repository to have all these utilities and packages in one place. Hopefully, you'll find them useful as well.

For more information, see the main repository.

Author

Oliver Nguyen  github

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce

func Coalesce[T comparable](list ...T) T

func CoalesceX

func CoalesceX[T any](list ...T) (out T)

func Deptr

func Deptr[T any](v *T) (out T)

func If

func If[T any](cond bool, a, b T) T

func In

func In[T comparable](item T, list ...T) bool

func IsNil added in v0.1.2

func IsNil(v any) bool

IsNil reports whether v is nil. Unlike reflect.IsNil(), it won't panic.

The Go team decided not to add "zero" to the language. https://github.com/golang/go/issues/61372

func IsZero added in v0.1.2

func IsZero[T comparable](v T) bool

IsZero reports whether v is zero. Unlike reflect.IsZero(), it won't panic.

The Go team decided not to add "zero" to the language. https://github.com/golang/go/issues/61372

func Ptr

func Ptr[T any](v T) *T

Types

This section is empty.

Jump to

Keyboard shortcuts

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