Init: lab4 done

This commit is contained in:
2025-11-07 05:26:09 +08:00
commit b55f254d82
23 changed files with 1140 additions and 0 deletions

33
cmds/root.go Normal file
View File

@@ -0,0 +1,33 @@
package cmds
import (
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
)
var RootCmd = &cobra.Command{
Use: "lab4",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
viper.BindPFlags(cmd.PersistentFlags())
viper.BindPFlags(cmd.Flags())
cfg := zap.NewProductionConfig()
logger, err := cfg.Build()
if err != nil {
panic(err)
}
zap.ReplaceGlobals(logger)
},
}
func init() {
cobra.EnableTraverseRunHooks = true
RootCmd.AddCommand(serverCmd)
}