Go Time

Guides the time package correctly — never compare time.Time with == (it compares the wall instant AND the monotonic reading AND the Location, so two values for the same instant can be unequal); use t.Equal/t.Before/t.After. Reference-layout formatting where the magic constant is the date "Mon Jan 2 15:04:05 MST 2006" (so "2006-01-02", not strftime %Y-%m-%d). time.Duration is an int64 of nanoseconds, so a bare integer is nanoseconds (time.Sleep(1) sleeps 1ns) — write typed literals like 5*time.Second. Stop tickers and don't leak time.After in hot loops; measure elapsed with time.Since (monotonic), not wall-clock subtraction; check the time.Parse error. Auto-invokes when writing or editing time.Time comparisons, time formatting/parsing layouts, time.Duration literals, timers/tickers, measuring elapsed time, or on "why does this time format look wrong" / "why is == on times false" requests. The layout is a date, not a format string; the surprises are all in the defaults.

ctoth 1d68984 3 files · 25.3 KB Updated

File contents

ctoth/golang-skills-plugin/tree/main/plugins/golang/skills/go-time commit 1d68984d71

Frequently asked questions

npx skillmds@latest add ctoth/go-time