mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
go-flag needs its own Unmarshaler.
This commit is contained in:
parent
1d892ff681
commit
125028773f
1 changed files with 6 additions and 1 deletions
|
|
@ -47,8 +47,13 @@ func guessDate(s string) (time.Time, bool) {
|
|||
|
||||
// UnmarshalText implements [encoding/text.TextUnmarshaler].
|
||||
func (tr *TimeRange) UnmarshalText(text []byte) error {
|
||||
return tr.UnmarshalFlag(string(text))
|
||||
}
|
||||
|
||||
// UnmarshalFlag implements [go-flags/Unmarshaler].
|
||||
func (tr *TimeRange) UnmarshalFlag(s string) error {
|
||||
s = strings.TrimSpace(s)
|
||||
|
||||
s := strings.TrimSpace(string(text))
|
||||
// Handle relative case first.
|
||||
if duration, err := time.ParseDuration(s); err == nil {
|
||||
now := time.Now()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue