Skip to content

Commit 66fcd08

Browse files
committed
printinfo代码优化
1 parent 9ee516a commit 66fcd08

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

sail/info.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,42 @@ func printSummaryInfo(conf config.HttpServerConf, ginEngine *gin.Engine) {
2020
protocol = "http:"
2121
messages bytes.Buffer
2222
localIp, _ = utils.IP().GetLocal()
23-
delimiter = []byte(strings.Repeat("=", 88))
24-
subDelimiter = []byte(strings.Repeat("-", 88))
23+
delimiter = strings.Repeat("=", 88)
24+
subDelimiter = strings.Repeat("-", 88)
2525
repoLink = "Repository: https://github.com/keepchen/go-sail"
2626
blank = strings.Repeat(" ", len(delimiter)-len(repoLink)-len(constants.GoSailVersion)-11)
2727
)
28-
messages.Write(delimiter)
28+
messages.WriteString(delimiter)
2929
info := fmt.Sprintf("%s\n", constants.GoSailLogo)
30-
messages.Write([]byte(info))
30+
messages.WriteString(info)
3131
versionInfo := fmt.Sprintf("\n%s%s(version: %s)\n", repoLink, blank, constants.GoSailVersion)
32-
messages.Write([]byte(versionInfo))
33-
messages.Write(subDelimiter)
34-
messages.Write([]byte("\n"))
32+
messages.WriteString(versionInfo)
33+
messages.WriteString(subDelimiter)
34+
messages.WriteString("\n")
3535
sMgs := fmt.Sprintf("[Server] Listening at: {%s}\n", conf.Addr)
36-
messages.Write([]byte(sMgs))
36+
messages.WriteString(sMgs)
3737
if conf.Debug {
3838
ginEngine.GET("/go-sail", func(c *gin.Context) {
3939
c.String(http.StatusOK, fmt.Sprintf("%s\r\n\r\n/** This route only enabled in debug mode **/", constants.GoSailLogo))
4040
})
4141
msg := fmt.Sprintf(">\t%s//%s%s%s\n", protocol, localIp, conf.Addr, "/go-sail")
42-
messages.Write([]byte(msg))
42+
messages.WriteString(msg)
4343
}
4444
if conf.Swagger.Enable {
4545
msg := fmt.Sprintf("[Swagger] Enabled:\n>\t%s//%s%s%s (Redocly UI)\n>\t%s//%s%s%s (Swagger UI)\n",
4646
protocol, localIp, conf.Addr, "/redoc/docs.html",
4747
protocol, localIp, conf.Addr, "/swagger/index.html")
48-
messages.Write([]byte(msg))
48+
messages.WriteString(msg)
4949
}
5050
if conf.Prometheus.Enable {
5151
msg := fmt.Sprintf("[Prometheus] Enabled:\n>\t%s//%s%s%s\n", protocol, localIp, conf.Prometheus.Addr, conf.Prometheus.AccessPath)
52-
messages.Write([]byte(msg))
52+
messages.WriteString(msg)
5353
}
5454
if conf.Debug {
5555
msg := fmt.Sprintf("[Pprof] Enabled:\n>\t%s//%s%s%s\n", protocol, localIp, conf.Addr, "/debug/pprof")
56-
messages.Write([]byte(msg))
56+
messages.WriteString(msg)
5757
}
58-
messages.Write(delimiter)
58+
messages.WriteString(delimiter)
5959

6060
fmt.Println(messages.String())
6161
}

0 commit comments

Comments
 (0)