Skip to content

Commit

Permalink
Fix some linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Rabot <[email protected]>
  • Loading branch information
sylr committed Jul 15, 2024
1 parent 74a1718 commit 0289daa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 7 additions & 6 deletions hey.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"math"
"net/http"
gourl "net/url"
Expand Down Expand Up @@ -108,7 +107,7 @@ Options:

func main() {
flag.Usage = func() {
fmt.Fprint(os.Stderr, fmt.Sprintf(usage, runtime.NumCPU()))
fmt.Fprintf(os.Stderr, usage, runtime.NumCPU())
}

var hs headerSlice
Expand Down Expand Up @@ -178,7 +177,7 @@ func main() {
bodyAll = []byte(*body)
}
if *bodyFile != "" {
slurp, err := ioutil.ReadFile(*bodyFile)
slurp, err := os.ReadFile(*bodyFile)
if err != nil {
errAndExit(err.Error())
}
Expand Down Expand Up @@ -257,7 +256,9 @@ func main() {
if f, err := os.OpenFile("cpu.prof", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666); err != nil {
errAndExit(err.Error())
} else {
pprof.StartCPUProfile(f)
if err := pprof.StartCPUProfile(f); err != nil {
errAndExit(err.Error())
}
defer pprof.StopCPUProfile()
}
}
Expand All @@ -266,14 +267,14 @@ func main() {
}

func errAndExit(msg string) {
fmt.Fprintf(os.Stderr, msg)
fmt.Fprint(os.Stderr, msg)
fmt.Fprintf(os.Stderr, "\n")
os.Exit(1)
}

func usageAndExit(msg string) {
if msg != "" {
fmt.Fprintf(os.Stderr, msg)
fmt.Fprint(os.Stderr, msg)
fmt.Fprintf(os.Stderr, "\n\n")
}
flag.Usage()
Expand Down
5 changes: 2 additions & 3 deletions requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"bytes"
"crypto/tls"
"io"
"io/ioutil"
"net/http"
"net/http/httptrace"
"net/url"
Expand Down Expand Up @@ -186,7 +185,7 @@ func (b *Work) makeRequest(c *http.Client) {
if err == nil {
size = resp.ContentLength
code = resp.StatusCode
io.Copy(ioutil.Discard, resp.Body)
_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}
t := now()
Expand Down Expand Up @@ -274,7 +273,7 @@ func cloneRequest(r *http.Request, body []byte) *http.Request {
r2.Header[k] = append([]string(nil), s...)
}
if len(body) > 0 {
r2.Body = ioutil.NopCloser(bytes.NewReader(body))
r2.Body = io.NopCloser(bytes.NewReader(body))
}
return r2
}
Expand Down

0 comments on commit 0289daa

Please sign in to comment.