Skip to content

Commit

Permalink
chore: add codacy coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
auula committed Sep 10, 2023
1 parent 7b889c7 commit d1e2b24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion clog/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func Error(v ...interface{}) {

func Failed(v ...interface{}) {
clog.Output(2, errorPrefix+fmt.Sprint(v...))
os.Exit(1)
}

func Warn(v ...interface{}) {
Expand Down
10 changes: 8 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func New(opt *conf.ServerConfig) *HttpServer {
hs := HttpServer{
Server: http.Server{
Handler: router.Root,
Addr: fmt.Sprintf("%s:%d", IPv4, opt.Port),
Addr: net.JoinHostPort(IPv4, string(opt.Port)),
WriteTimeout: 3 * time.Second,
ReadTimeout: 3 * time.Second,
},
Expand All @@ -54,6 +54,7 @@ func (hs *HttpServer) Startup() {
clog.Info("Receiving client connections")
if err := hs.ListenAndServe(); err != nil {
clog.Failed(err)
panic(err)
}
}()

Expand All @@ -66,11 +67,16 @@ func (hs *HttpServer) Startup() {
}

func (hs *HttpServer) Shutdown() {

if hs.closed == 0 {
clog.Failed("HTTP server not started")
err := "HTTP server not started"
clog.Failed(err)
panic(err)
}

if err := hs.Server.Shutdown(context.Background()); err != nil {
clog.Failed(err)
panic(err)
}

atomic.StoreInt32(&hs.closed, 1)
Expand Down
3 changes: 2 additions & 1 deletion utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package utils

import "strings"

// trimDaemon 从 os.Args 中移除 "-daemon" 参数
// TrimDaemon 从 os.Args 中移除 "-daemon" 参数
func TrimDaemon(args []string) []string {
var newArgs []string

Expand All @@ -19,6 +19,7 @@ func TrimDaemon(args []string) []string {
return newArgs
}

// SplitArgs 处理命令行参数以 = 分割
func SplitArgs(args []string) []string {
var newArgs []string
// i = 1 避免处理 ./vasedb 本身
Expand Down

0 comments on commit d1e2b24

Please sign in to comment.