bug: time.Duration fields reject systemd's own duration syntax #17
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
encoding/systemd/marshal_decode.go,setFieldValue(~lines 243–251), thetime.Durationspecial case calls Go'stime.ParseDurationdirectly.time.ParseDurationonly understands Go's own unit spelling and syntax and does not understand systemd'ssystemd.time(7)grammar: bare integers meaning seconds (e.g."30"), theminunit, or space-separated compound spans (e.g."1min 30s") — all of which are standard, commonly-seen systemd unit file values.Marshal's corresponding encode path (formatValueinmarshal_encode.go) has the matching gap: it emits Go'sDuration.String()format (e.g."1m30s"), not systemd's.Reproduction
Recommended fix
Write a small systemd-time-span parser (bare integer → seconds; support
us/usec,ms/msec,s/sec/second(s),m/min/minute(s),h/hr/hour(s),d/day(s),w/week(s), space-separated sums) for the decode side, and emit systemd-style unit suffixes on the encode side, rather than delegating straight totime.ParseDuration/Duration.String().