Skip to content

Commit 56158c8

Browse files
authored
Merge pull request #35 from cpaillet/main
fix(serializer): remove dead code fix(api): handle fmt.Fprintf errors
2 parents 59529fc + 2933a3a commit 56158c8

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

internal/api/router/endpoints.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ const wildcard = "*"
1919

2020
func healthCheck(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
2121
w.Header().Set(contentType, applicationJSON)
22-
fmt.Fprintf(w, `{"status": "ok"}`)
22+
_, _ = fmt.Fprintf(w, `{"status": "ok"}`)
2323
}
2424

2525
func getVersion(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
2626
w.Header().Set(contentType, applicationJSON)
27-
fmt.Fprintf(w, `{"version": "%s", "build_time": "%s", "build_user": "%s"}`, app.Info.Version, app.Info.BuildTime, app.Info.BuildUser)
27+
_, _ = fmt.Fprintf(w, `{"version": "%s", "build_time": "%s", "build_user": "%s"}`, app.Info.Version, app.Info.BuildTime, app.Info.BuildUser)
2828
}
2929

3030
func prometheusMetrics(h http.Handler) httprouter.Handle {

internal/convertor/device/serializer.go

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package device
22

33
import (
4-
"bytes"
54
"encoding/json"
65
"errors"
76

@@ -94,18 +93,12 @@ func (s *SafeRepository) GetDeviceOpenConfigJSON(hostname string) ([]byte, error
9493

9594
var config json.RawMessage
9695
var err error
97-
out := bytes.NewBuffer(nil)
9896

9997
if config, err = dev.GetCompactJSON(); err != nil {
10098
log.Error().Err(err).Send()
10199
return []byte(emptyJSON), err
102100
}
103101

104-
if err := json.Compact(out, []byte(dev.Config.JSON)); err != nil {
105-
log.Error().Err(err).Send()
106-
return []byte(emptyJSON), err
107-
}
108-
109102
if r, err := json.Marshal(config); err != nil {
110103
log.Error().Err(err).Send()
111104
return []byte(emptyJSON), err

0 commit comments

Comments
 (0)