updatestamp

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

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

Overview

Package updatestamp is the per-record last-write stamp: one sortable token that keeps the timestamp and the device tiebreaker from ever drifting apart. It is the Go counterpart of lib/tasks/update_stamp.rb.

The whole value object lives here — validation, the ordering key, comparison, and formatting — because the stamp is what decides last-write-wins when two devices edited the same record. A second spelling of "which stamp is newer" living in the merge path would be a second answer waiting to diverge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(left, right string) int

Compare orders two stamps the way UpdateStamp.compare does: -1, 0, or 1.

An unparseable or absent stamp sorts BEFORE every real one, and two of them compare equal. That is the rule last-write-wins depends on: a record whose stamp a hand edit destroyed must never win against a record that carries a real one, and it must not oscillate when neither side has one.

func Device

func Device(env determinism.Env) string

Device is the device slug for this process: TASKS_DEVICE when it is set to anything but blank, otherwise the hostname — resolved through Determinism so that one pin covers both hostname consumers.

func Format

func Format(instant time.Time, device string) string

Format renders the stamp a writer stores: the instant in UTC, then the device slug. Ruby additionally raises on an empty slug; Slug cannot return one (it falls back to "device"), so the guard is unreachable in both languages and is not reproduced as an error return.

func Key

func Key(value string) (timestamp, device string, ok bool)

Key is the ordering key of a stamp: its timestamp half and its device half, or ok=false when the value is not a stamp at all. The two are compared in that order, which is why the stored spelling is one token — sorting the file by `updated` and sorting it by (timestamp, device) are the same sort.

func Max

func Max(left, right string) string

Max is the later of two stamps, preferring the LEFT one on a tie — the same bias Ruby's `compare(left, right).negative? ? right : left` has, so a merge that finds two equal stamps keeps the value it already held.

func Slug

func Slug(value string) string

Slug reduces a hostname to its first alphanumeric token. Hostnames commonly look like Marcus-MBP.local; the first token is stable and short while still letting an explicit TASKS_DEVICE disambiguate similar machines.

func Valid

func Valid(value string) bool

Valid reports whether a stored `updated` value is a well-formed stamp: an RFC3339 UTC timestamp naming a real instant, then the device slug.

Types

This section is empty.

Jump to

Keyboard shortcuts

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