aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index ba1614f..776c698 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -5,6 +5,7 @@ import (
"io"
"strconv"
+ "git.gabrielgio.me/cerrado/pkg/u"
"git.sr.ht/~emersion/go-scfg"
)
@@ -56,9 +57,9 @@ func setScan(block scfg.Block, scan *Scan) error {
}
func setBool(dir *scfg.Directive, field *bool) error {
-
if dir != nil {
- p1 := first(dir.Params)
+
+ p1, _ := u.First(dir.Params)
v, err := strconv.ParseBool(p1)
if err != nil {
return fmt.Errorf("Error parsing bool param of %s: %w", dir.Name, err)
@@ -70,15 +71,7 @@ func setBool(dir *scfg.Directive, field *bool) error {
func setString(dir *scfg.Directive, field *string) error {
if dir != nil {
- *field = first(dir.Params)
+ *field, _ = u.First(dir.Params)
}
return nil
}
-
-func first[T any](v []T) T {
- if len(v) == 0 {
- var zero T
- return zero
- }
- return v[0]
-}