Feat: done tcp

This commit is contained in:
2025-11-10 10:02:55 +08:00
parent 78d89595a1
commit 9a39bcda40
17 changed files with 689 additions and 0 deletions

34
cmds/root.go Normal file
View File

@@ -0,0 +1,34 @@
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)
RootCmd.AddCommand(clientCmd)
}