gg

package
v0.52.5 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 0 Imported by: 1

Documentation

Overview

Package gg implements simple "extensions" to Go language. Based on https://github.com/icza/gog

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstOr

func FirstOr[T comparable](or T, values ...T) T

FirstOr is a generic helper function that returns the first non-zero value from a list of comparable values, or a default value if all the values are zero.

func If

func If[T comparable](v T, orElse T) T

If returns v if it is a non-zero value, orElse otherwise.

This is similar to elvis operator (?:) in Groovy and other languages. Note: Different from the real elvis operator, the orElse expression will always get evaluated.

func P added in v0.51.1

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

P returns a pointer to the input value

func V added in v0.51.1

func V[T any](p *T) T

V returns the value of the input pointer, or a zero value if the input pointer is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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