compare

package
v0.2.30 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "compare" namespace.

func New

func New(loc *time.Location, caseInsensitive bool) *Namespace

New returns a new instance of the compare-namespaced template functions.

func (*Namespace) Conditional

func (n *Namespace) Conditional(cond bool, v1, v2 any) any

Conditional can be used as a ternary operator.

It returns v1 if cond is true, else v2.

func (*Namespace) Default

func (*Namespace) Default(defaultv any, givenv ...any) (any, error)

Default checks whether a givenv is set and returns the default value defaultv if it is not. "Set" in this context means non-zero for numeric types and times; non-zero length for strings, arrays, slices, and maps; any boolean or struct value; or non-nil for any other types.

func (*Namespace) Eq

func (n *Namespace) Eq(first any, others ...any) bool

Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4.

func (*Namespace) Ge

func (n *Namespace) Ge(first any, others ...any) bool

Ge returns the boolean truth of arg1 >= arg2 && arg1 >= arg3 && arg1 >= arg4.

func (*Namespace) Gt

func (n *Namespace) Gt(first any, others ...any) bool

Gt returns the boolean truth of arg1 > arg2 && arg1 > arg3 && arg1 > arg4.

func (*Namespace) Le

func (n *Namespace) Le(first any, others ...any) bool

Le returns the boolean truth of arg1 <= arg2 && arg1 <= arg3 && arg1 <= arg4.

func (*Namespace) Lt

func (n *Namespace) Lt(first any, others ...any) bool

Lt returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4.

func (*Namespace) LtCollate

func (n *Namespace) LtCollate(collator *collate.Collator, first any, others ...any) bool

LtCollate returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4. The provided collator will be used for string comparisons. This is for internal use.

func (*Namespace) Ne

func (n *Namespace) Ne(first any, others ...any) bool

Ne returns the boolean truth of arg1 != arg2 && arg1 != arg3 && arg1 != arg4.

type TimeZone

type TimeZone interface {
	Location() *time.Location
}

Jump to

Keyboard shortcuts

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