collections.Uniq
Returns a slice by removing duplicate elements from the given slice.
- Syntax
- collections.Uniq SLICE
- Returns
- []any
- Alias
- uniq
{{ slice 1 3 2 1 | uniq }} → [1 3 2]The function compares time.Time values by the moment they represent, regardless of time zone:
{{ $utc := time.AsTime "2023-07-19T17:42:36Z" }}
{{ $tokyo := $utc | time.In "Asia/Tokyo" }}
{{ slice $utc $tokyo | uniq | len }} → 1