Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
cleanup code base: reformat some code based on staticcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Guangming Wang <[email protected]>
  • Loading branch information
Guangming Wang committed Sep 24, 2019
1 parent 2f3ca58 commit 75e6931
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ func (client *APIClient) newRequest(method, path string, query url.Values, body
return nil, err
}

if header != nil {
for k, v := range header {
req.Header[k] = v
}
for k, v := range header {
req.Header[k] = v
}

return req, err
Expand Down
1 change: 0 additions & 1 deletion dfget/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,4 @@ func reportMetrics(cfg *config.Config, supernodeAPI api.SupernodeAPI, downloadTi
return
}
}
return
}
6 changes: 3 additions & 3 deletions dfget/core/uploader/peer_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ func (ps *peerServer) parseRateHandler(w http.ResponseWriter, r *http.Request) {

// no need to calculate rate when totalLimitRate less than or equals zero.
if ps.totalLimitRate <= 0 {
fmt.Fprintf(w, rateLimit)
fmt.Fprint(w, rateLimit)
return
}

clientRate = ps.calculateRateLimit(clientRate)

fmt.Fprintf(w, strconv.Itoa(clientRate))
fmt.Fprint(w, strconv.Itoa(clientRate))
}

// checkHandler use to check the server status.
Expand Down Expand Up @@ -234,7 +234,7 @@ func (ps *peerServer) checkHandler(w http.ResponseWriter, r *http.Request) {
func (ps *peerServer) oneFinishHandler(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
sendHeader(w, http.StatusBadRequest)
fmt.Fprintf(w, err.Error())
fmt.Fprint(w, err.Error())
return
}

Expand Down
2 changes: 1 addition & 1 deletion dfget/core/uploader/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func launch(cfg *config.Config, p2pPtr *unsafe.Pointer) error {
tmp := newPeerServer(cfg, port)
storeSrvPtr(p2pPtr, tmp)
if err := tmp.ListenAndServe(); err != nil {
if strings.Index(err.Error(), "address already in use") < 0 {
if !strings.Contains(err.Error(), "address already in use") {
// start failed or shutdown
return err
} else if uploaderAPI.PingServer(tmp.host, tmp.port) {
Expand Down
1 change: 0 additions & 1 deletion supernode/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func filter(handler Handler) http.HandlerFunc {
// Handle error if request handling fails.
HandleErrorResponse(w, err)
}
return
}
}

Expand Down

0 comments on commit 75e6931

Please sign in to comment.