配置文件读取
This commit is contained in:
@@ -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"`
|
||||
}
|
||||
Reference in New Issue
Block a user