2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00

fix: lint

This commit is contained in:
2025-04-12 05:55:18 +08:00
parent 0b0c4da3eb
commit 3b7bf35bf3
2 changed files with 7 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ func (s *App) Route(r chi.Router) {
func (s *App) Load(w http.ResponseWriter, r *http.Request) {
status, err := systemctl.Status("memcached")
if err != nil {
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to get Memcached status: %v"), err)
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to get Memcached status: %v", err))
return
}
if !status {
@@ -53,7 +53,7 @@ func (s *App) Load(w http.ResponseWriter, r *http.Request) {
_, err = conn.Write([]byte("stats\nquit\n"))
if err != nil {
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to write to Memcached: %v"), err)
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to write to Memcached: %v", err))
return
}
@@ -74,7 +74,7 @@ func (s *App) Load(w http.ResponseWriter, r *http.Request) {
}
if err = scanner.Err(); err != nil {
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to read from Memcached: %v"), err)
service.Error(w, http.StatusInternalServerError, s.t.Get("failed to read from Memcached: %v", err))
return
}

View File

@@ -39,8 +39,11 @@ func Error(w http.ResponseWriter, code int, format string, args ...any) {
defer render.Release()
render.Header(chix.HeaderContentType, chix.MIMEApplicationJSONCharsetUTF8) // must before Status()
render.Status(code)
if len(args) > 0 {
format = fmt.Sprintf(format, args...)
}
render.JSON(&ErrorResponse{
Message: fmt.Sprintf(format, args...),
Message: format,
})
}