mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 21:02:11 +08:00
refactor: cmd update.
This commit is contained in:
parent
ba25beff94
commit
3756ba90a6
@ -15,7 +15,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ func NewRootCmd(processName string, opts ...func(*CmdOpts)) *RootCmd {
|
|||||||
|
|
||||||
func (r *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error {
|
func (r *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error {
|
||||||
cmdOpts := r.applyOptions(opts...)
|
cmdOpts := r.applyOptions(opts...)
|
||||||
log.CInfo(context.Background(), "config", cmdOpts.configMap)
|
fmt.Println("config", cmdOpts.configMap)
|
||||||
if err := r.initializeConfiguration(cmd, cmdOpts); err != nil {
|
if err := r.initializeConfiguration(cmd, cmdOpts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"fmt"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -25,6 +24,6 @@ func LoadConfig(path string, envPrefix string, config any) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
|
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
|
||||||
}
|
}
|
||||||
log.CInfo(context.Background(), "Load config success", "path", path, "envPrefix", envPrefix, "config", config)
|
fmt.Print("Load config success", "path", path, "envPrefix", envPrefix, "config", config)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user