配置文件读取

This commit is contained in:
Yun
2024-03-13 14:10:15 +08:00
commit d5217ba990
5 changed files with 599 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
package viperx_test
import (
"fmt"
"testing"
"code.yun.ink/pkg/viperx"
)
func TestViper(t *testing.T) {
var data Config
err := viperx.InitConfig("./config.yml", &data)
if err != nil {
panic(err)
}
fmt.Println(data)
}
type Config struct {
Name string `mapstructure:"name" json:"name" yaml:"name"`
}