Skip to content

Commit 4ef2b34

Browse files
committed
Add lint option to Makefile and fix lint issues
1 parent 930c69a commit 4ef2b34

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ Note: if you’d like to implement a new feature, please consider creating a fea
6464
* Run `gofmt` over your code to automatically resolve a lot of style issues. Most editors support this running automatically when saving a code file.
6565
* Run `go lint` and `go vet` on your code too to catch any other issues.
6666
* Follow this guide on some good practice and idioms for Go - https://github.com/golang/go/wiki/CodeReviewComments
67+
* To check for extra issues, install [golangci-lint](https://github.com/golangci/golangci-lint) and run `make lint` or `golangci-lint run`

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ BUILD_DIR = build_output
88
nginx-prometheus-exporter: test
99
CGO_ENABLED=0 go build -installsuffix cgo -ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT)" -o nginx-prometheus-exporter
1010

11+
lint:
12+
golangci-lint run
13+
1114
test:
1215
go test ./...
1316

exporter.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,16 @@ func main() {
176176
}
177177
http.Handle(*metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
178178
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
179-
w.Write([]byte(`<html>
179+
_, err := w.Write([]byte(`<html>
180180
<head><title>NGINX Exporter</title></head>
181181
<body>
182182
<h1>NGINX Exporter</h1>
183183
<p><a href='/metrics'>Metrics</a></p>
184184
</body>
185185
</html>`))
186+
if err != nil {
187+
log.Printf("Error while sending a response for the '/' path: %v", err)
188+
}
186189
})
187190
log.Printf("NGINX Prometheus Exporter has successfully started")
188191
log.Fatal(http.ListenAndServe(*listenAddr, nil))

0 commit comments

Comments
 (0)