feat: decode conf error msg

This commit is contained in:
张泊明518370910136 2024-09-30 00:48:27 -04:00
parent 7b3edb2361
commit 3682a36fde
GPG Key ID: D47306D7062CDA9D

View File

@ -1,12 +1,16 @@
package stage package stage
import "github.com/mitchellh/mapstructure" import (
"fmt"
"github.com/mitchellh/mapstructure"
)
func DecodeConf[T any](confAny any) (*T, error) { func DecodeConf[T any](confAny any) (*T, error) {
var conf T var conf T
err := mapstructure.Decode(confAny, &conf) err := mapstructure.Decode(confAny, &conf)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("failed to decode conf: %w", err)
} }
return &conf, nil return &conf, nil
} }