aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/common/scfg/struct.go
diff options
context:
space:
mode:
Diffstat (limited to 'forged/internal/common/scfg/struct.go')
-rw-r--r--forged/internal/common/scfg/struct.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/forged/internal/common/scfg/struct.go b/forged/internal/common/scfg/struct.go
index 98ec943..c222385 100644
--- a/forged/internal/common/scfg/struct.go
+++ b/forged/internal/common/scfg/struct.go
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: Copyright (c) 2020 Simon Ser <https://emersion.fr>
+// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
-package scfg
+package scfgs
import (
"fmt"
@@ -10,7 +11,7 @@ import (
"sync"
)
-// structInfo contains scfg metadata for structs.
+// structInfo contains scfgs metadata for structs.
type structInfo struct {
param int // index of field storing parameters
children map[string]int // indices of fields storing child directives
@@ -37,12 +38,12 @@ func getStructInfo(t reflect.Type) (*structInfo, error) {
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if f.Anonymous {
- return nil, fmt.Errorf("scfg: anonymous struct fields are not supported")
+ return nil, fmt.Errorf("scfgs: anonymous struct fields are not supported")
} else if !f.IsExported() {
continue
}
- tag := f.Tag.Get("scfg")
+ tag := f.Tag.Get("scfgs")
parts := strings.Split(tag, ",")
k, options := parts[0], parts[1:]
if k == "-" {
@@ -57,21 +58,21 @@ func getStructInfo(t reflect.Type) (*structInfo, error) {
case "param":
isParam = true
default:
- return nil, fmt.Errorf("scfg: invalid option %q in struct tag", opt)
+ return nil, fmt.Errorf("scfgs: invalid option %q in struct tag", opt)
}
}
if isParam {
if info.param >= 0 {
- return nil, fmt.Errorf("scfg: param option specified multiple times in struct tag in %v", t)
+ return nil, fmt.Errorf("scfgs: param option specified multiple times in struct tag in %v", t)
}
if parts[0] != "" {
- return nil, fmt.Errorf("scfg: name must be empty when param option is specified in struct tag in %v", t)
+ return nil, fmt.Errorf("scfgs: name must be empty when param option is specified in struct tag in %v", t)
}
info.param = i
} else {
if _, ok := info.children[k]; ok {
- return nil, fmt.Errorf("scfg: key %q specified multiple times in struct tag in %v", k, t)
+ return nil, fmt.Errorf("scfgs: key %q specified multiple times in struct tag in %v", k, t)
}
info.children[k] = i
}