first

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 0 Imported by: 9

README

first

The "coalesce" helper: first.String(...), first.Int(...), and first.Int64(...) each return the first non-zero/non-empty value from their variadic arguments, or the type's zero value if every argument is empty. Part of rosetta.

Go Reference

Useful for fallback chains — first.String(userValue, configValue, defaultValue). There's nothing subtle here; it's three short loops.

Documentation

Overview

Package first returns the first non-empty value from a list of candidates.

It exists for the fallback chains that show up all over configuration and display code — use the value the caller passed, otherwise the one on the record, otherwise a hard-coded default — written as a single expression instead of a ladder of if statements. Emptiness means the zero value for the type, and if every candidate is empty, that zero value is what comes back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int

func Int(values ...int) int

Int returns the first non-zero value in the argument list

func Int64

func Int64(values ...int64) int64

Int64 returns the first non-zero value in the argument list

func String

func String(values ...string) string

String returns the first non-empty value in the argument list

Types

This section is empty.

Jump to

Keyboard shortcuts

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