add bannner

This commit is contained in:
kingecg 2023-11-28 23:26:58 +08:00
parent 10c818e063
commit c67da73f30
4 changed files with 68 additions and 7 deletions

7
.vscode/launch.json vendored
View File

@ -9,7 +9,12 @@
"type": "go", "type": "go",
"request": "launch", "request": "launch",
"mode": "auto", "mode": "auto",
"program": "${fileDirname}" "program": "${fileDirname}",
"args": [
"--config",
"config.json",
"version"
]
}, },
{ {
"name": "Launch file", "name": "Launch file",

View File

@ -4,15 +4,34 @@ import (
"fmt" "fmt"
"os" "os"
"git.pyer.club/kingecg/gologger"
"git.pyer.club/kingecg/gosocketio/config"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var rootCmd = &cobra.Command{ var (
Use: "gosocketio", configFile string
Short: "A golang socket.io server", rootCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Use: "gosocketio",
fmt.Println("gossocketio called") Short: "A golang socket.io server",
}, Run: func(cmd *cobra.Command, args []string) {
},
}
)
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file")
}
func initConfig() {
if configFile != "" {
config.LoadConfig(configFile)
}
gologger.Configure(config.GetConfig().Logging)
logger := gologger.GetLogger("main")
logger.Debug("On init")
} }
// run app cmd // run app cmd

23
config.json Normal file
View File

@ -0,0 +1,23 @@
{
"host": "localhost",
"port": 3306,
"logging": {
"appenders": {
"out": {
"type": "console"
},
"server": {
"type": "file",
"options":{
"file": "./logs/server.log"
}
}
},
"categories": {
"default": {
"appenders": ["out","server"],
"level": "debug"
}
}
}
}

14
main.go
View File

@ -1,9 +1,23 @@
package main package main
import ( import (
"fmt"
"git.pyer.club/kingecg/gosocketio/cli" "git.pyer.club/kingecg/gosocketio/cli"
) )
const title string = `
___ __ _ _____ __
/ _ \___ / _\ ___ ___| | _____ \_ \___ / _\ ___ _ ____ _____ _ __
/ /_\/ _ \ \ \ / _ \ / __| |/ / _ \ / /\/ _ \ \ \ / _ \ '__\ \ / / _ \ '__|
/ /_\\ (_) | _\ \ (_) | (__| < __/\/ /_| (_) | _\ \ __/ | \ V / __/ |
\____/\___/ \__/\___/ \___|_|\_\___\____/ \___/ \__/\___|_| \_/ \___|_|
`
func main() { func main() {
fmt.Print(title)
cli.Execute() cli.Execute()
} }