build(deps): require kvconf v0.1.0
- commit
- 8ec4bfc7386d1a8f01af550330e13a047e2c0d49
- author
- brice · · 2026-10-10 03:25 UTC
- parent
- 1894f55
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +6 -4
M go.sum +2 -0 generated file: collapsed
M internal/adapters/config/config.go +4 -4
| @@ -61,7 +61,7 @@ func (o *onOff) UnmarshalText(text []byte) error { | |||
| 61 | 61 | case "off": | |
| 62 | 62 | *o = false | |
| 63 | 63 | default: | |
| 64 | - | return errors.New("must be on or off") | |
| 64 | + | return kvconf.ValueError("must be on or off") | |
| 65 | 65 | } | |
| 66 | 66 | return nil | |
| 67 | 67 | } | |
| @@ -71,10 +71,10 @@ type dirPath string | |||
| 71 | 71 | ||
| 72 | 72 | func (d *dirPath) UnmarshalText(text []byte) error { | |
| 73 | 73 | if len(text) > maxPath { | |
| 74 | - | return errors.New("must be a non-empty path") | |
| 74 | + | return kvconf.ValueError("must be a non-empty path") | |
| 75 | 75 | } | |
| 76 | 76 | if string(text) == "~" { | |
| 77 | - | return errors.New("must be an absolute path or start with ~/") | |
| 77 | + | return kvconf.ValueError("must be an absolute path or start with ~/") | |
| 78 | 78 | } | |
| 79 | 79 | var p kvconf.Path | |
| 80 | 80 | if err := p.UnmarshalText(text); err != nil { | |
| @@ -100,7 +100,7 @@ func Load() (Settings, error) { | |||
| 100 | 100 | return settings, nil | |
| 101 | 101 | case errors.Is(err, kvconf.ErrTooLarge): | |
| 102 | 102 | return Settings{}, fmt.Errorf("config %s exceeds %d bytes", path, maxBytes) | |
| 103 | - | case err != nil && strings.HasSuffix(err.Error(), "not a regular file"): | |
| 103 | + | case errors.Is(err, kvconf.ErrNotRegular): | |
| 104 | 104 | return Settings{}, fmt.Errorf("config %s: expected a regular file", path) | |
| 105 | 105 | case err != nil: | |
| 106 | 106 | return Settings{}, fmt.Errorf("read config: %w", err) | |
| @@ -61,7 +61,7 @@ func (o *onOff) UnmarshalText(text []byte) error { | |||||
| 61 | case "off": | 61 | case "off": | ||
| 62 | *o = false | 62 | *o = false | ||
| 63 | default: | 63 | default: | ||
| 64 | - | return errors.New("must be on or off") | 64 | + | return kvconf.ValueError("must be on or off") |
| 65 | } | 65 | } | ||
| 66 | return nil | 66 | return nil | ||
| 67 | } | 67 | } | ||
| @@ -71,10 +71,10 @@ type dirPath string | |||||
| 71 | 71 | ||||
| 72 | func (d *dirPath) UnmarshalText(text []byte) error { | 72 | func (d *dirPath) UnmarshalText(text []byte) error { | ||
| 73 | if len(text) > maxPath { | 73 | if len(text) > maxPath { | ||
| 74 | - | return errors.New("must be a non-empty path") | 74 | + | return kvconf.ValueError("must be a non-empty path") |
| 75 | } | 75 | } | ||
| 76 | if string(text) == "~" { | 76 | if string(text) == "~" { | ||
| 77 | - | return errors.New("must be an absolute path or start with ~/") | 77 | + | return kvconf.ValueError("must be an absolute path or start with ~/") |
| 78 | } | 78 | } | ||
| 79 | var p kvconf.Path | 79 | var p kvconf.Path | ||
| 80 | if err := p.UnmarshalText(text); err != nil { | 80 | if err := p.UnmarshalText(text); err != nil { | ||
| @@ -100,7 +100,7 @@ func Load() (Settings, error) { | |||||
| 100 | return settings, nil | 100 | return settings, nil | ||
| 101 | case errors.Is(err, kvconf.ErrTooLarge): | 101 | case errors.Is(err, kvconf.ErrTooLarge): | ||
| 102 | return Settings{}, fmt.Errorf("config %s exceeds %d bytes", path, maxBytes) | 102 | return Settings{}, fmt.Errorf("config %s exceeds %d bytes", path, maxBytes) | ||
| 103 | - | case err != nil && strings.HasSuffix(err.Error(), "not a regular file"): | 103 | + | case errors.Is(err, kvconf.ErrNotRegular): |
| 104 | return Settings{}, fmt.Errorf("config %s: expected a regular file", path) | 104 | return Settings{}, fmt.Errorf("config %s: expected a regular file", path) | ||
| 105 | case err != nil: | 105 | case err != nil: | ||
| 106 | return Settings{}, fmt.Errorf("read config: %w", err) | 106 | return Settings{}, fmt.Errorf("read config: %w", err) | ||