Skip to content

Commit 7d8b455

Browse files
committed
Fix lint issues
I've got used to having `cargo clippy` when doing Rust development. This addresses similar nagging things about ignoring return values, using deprecated APIs in the 6 years since this was first written. I do like the Go 1.x thing that it nothing broke.
1 parent 26b3700 commit 7d8b455

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

main.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"net/http"
98
"net/http/httptrace"
109
"os"
@@ -57,7 +56,7 @@ func main() {
5756
flag.Parse()
5857

5958
if version {
60-
fmt.Fprintf(os.Stderr, "httptraced: version 0.0.1\n")
59+
_, _ = fmt.Fprintf(os.Stderr, "httptraced: version 0.0.1\n")
6160
os.Exit(1)
6261
}
6362

@@ -85,7 +84,7 @@ func main() {
8584
}
8685

8786
func showUsage() {
88-
fmt.Fprintf(os.Stderr, usage)
87+
_, _ = fmt.Fprintf(os.Stderr, usage)
8988
flag.PrintDefaults()
9089
}
9190

@@ -97,7 +96,7 @@ func (j *JSONTimestamp) MarshalJSON() ([]byte, error) {
9796
}
9897

9998
type JSONError struct {
100-
Detail string `json:detail`
99+
Detail string `json:"detail"`
101100
}
102101

103102
type JSONOutput struct {
@@ -176,7 +175,7 @@ func doPoll(URL string, encoder *json.Encoder) {
176175
write(encoder,
177176
JSONOutput{
178177
Errors: []JSONError{
179-
JSONError{Detail: err.Error()},
178+
{Detail: err.Error()},
180179
},
181180
})
182181
return
@@ -211,19 +210,19 @@ func doIt(URL string) (*TimingContext, error) {
211210
return nil, err
212211
}
213212

214-
if _, err := io.Copy(ioutil.Discard, res.Body); err != nil {
213+
if _, err := io.Copy(io.Discard, res.Body); err != nil {
215214
return nil, err
216215
}
217216

218217
timingContext.Total = timingContext.Elapsed()
219218

220-
res.Body.Close()
219+
_ = res.Body.Close()
221220

222221
return timingContext, nil
223222
}
224223

225224
func write(encoder *json.Encoder, jo JSONOutput) {
226225
if err := encoder.Encode(jo); err != nil {
227-
fmt.Fprintln(os.Stderr, err.Error())
226+
_, _ = fmt.Fprintln(os.Stderr, err.Error())
228227
}
229228
}

0 commit comments

Comments
 (0)