Document Duration wrapper type usage

- config package doc: explain Duration fields, TOML format, env vars
- duration.go: expanded godoc with access pattern examples
- README: show .Duration access in quick start

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 15:39:14 -07:00
parent 96d420ac82
commit 9e98eb0a21
3 changed files with 33 additions and 2 deletions

View File

@@ -5,9 +5,18 @@ import (
"time"
)
// Duration is a time.Duration that can be unmarshalled from a TOML string
// Duration is a [time.Duration] that can be unmarshalled from a TOML string
// (e.g., "30s", "5m"). go-toml v2 does not natively decode strings into
// time.Duration, so this wrapper implements encoding.TextUnmarshaler.
// time.Duration, so this wrapper implements [encoding.TextUnmarshaler].
//
// Access the underlying time.Duration via the embedded field:
//
// cfg.Server.ReadTimeout.Duration // time.Duration value
//
// Duration values work directly with time functions that accept
// time.Duration because of the embedding:
//
// time.After(cfg.Server.ReadTimeout.Duration)
type Duration struct {
time.Duration
}