From db03e1a2a84b5edfd95ce190c849eb5afa5a464e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Wed, 12 Nov 2025 00:31:04 +0800 Subject: Update README --- forged/internal/common/scfg/struct.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'forged/internal/common/scfg/struct.go') 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 +// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu -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 } -- cgit v1.2.3