Skip to content

Commit 2c3ab0f

Browse files
committed
viper
1 parent 06bcde5 commit 2c3ab0f

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

psdk/conf/viper.go

+5-21
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
type ConfigCtx struct {
11-
viper *viper.Viper
11+
*viper.Viper
1212
context.Context
1313
fmt.Stringer
1414
}
@@ -20,39 +20,23 @@ func WithContext(ctx context.Context) *ConfigCtx {
2020
v.AddConfigPath(".")
2121
v.AutomaticEnv()
2222

23-
return &ConfigCtx{viper: v, Context: ctx}
23+
return &ConfigCtx{Viper: v, Context: ctx}
2424
}
2525

26-
func (c *ConfigCtx) SetConfigName(name string) {
27-
c.viper.SetConfigName(name)
28-
}
29-
30-
func (c *ConfigCtx) SetConfigType(typ string) {
31-
c.viper.SetConfigType(typ)
32-
}
33-
34-
func (c *ConfigCtx) AddConfigPath(paths ...string) {
26+
func (c *ConfigCtx) AddConfigPaths(paths ...string) {
3527
for _, path := range paths {
36-
c.viper.AddConfigPath(path)
28+
c.Viper.AddConfigPath(path)
3729
}
3830
}
3931

40-
func (c *ConfigCtx) ReadInConfig() error {
41-
return c.viper.ReadInConfig()
42-
}
43-
44-
func (c *ConfigCtx) Unmarshal(v any) error {
45-
return c.viper.Unmarshal(v)
46-
}
47-
4832
func (c *ConfigCtx) Value(key any) any {
4933
vk, ok := key.(string)
5034

5135
if !ok {
5236
return c.Context.Value(key)
5337
}
5438

55-
if val := c.viper.Get(vk); val != nil {
39+
if val := c.Viper.Get(vk); val != nil {
5640
return val
5741
}
5842
return c.Context.Value(key)

wxlogin/cmd/wxlogin/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ func main() {
4444
if err := webx.ListenAndServe(appConf.Web.Addr, root); err != nil {
4545
log.Fatal(err)
4646
}
47-
4847
}

0 commit comments

Comments
 (0)