Packages
pkg/utils
Tiny domain-independent helpers. New projects also get pkg/utils/utils.go from the CLI scaffold — keep business rules in internal/<module>.
Usage
import "github.com/BounkhongDev/bkgo/pkg/utils"
name := utils.Coalesce("", "guest") // "guest"
tags := utils.Unique([]string{"go", "go", "api"}) // ["go", "api"]Signatures
// Coalesce returns the first non-zero value, or the zero value if none is provided.
func Coalesce[T comparable](values ...T) T
// Unique returns a new slice with duplicates removed, preserving first-seen order.
// A nil input returns nil. The input is never modified.
func Unique[T comparable](values []T) []TNotes
- •Import the library path
github.com/BounkhongDev/bkgo/pkg/utils, or your project's ownpkg/utilscopy. - •
CoalesceandUniqueare generic over comparable types. - •Do not put product rules (pricing, roles, order state) in utils.