From 56b0d6067d0acc9a212e94cec86f9e73121347f7 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Fri, 10 Apr 2026 13:33:50 +0200 Subject: [PATCH] Improve linting * Update build badge. * Enable `revive` linter. * Fix linting issues. Signed-off-by: SuperQ --- .golangci.yml | 1 + README.md | 3 +-- cmd/consul_exporter/consul_exporter.go | 10 +++++----- pkg/exporter/consul_exporter.go | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5c0378c..3f099fe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,6 +2,7 @@ version: "2" linters: enable: - sloglint + - revive settings: errcheck: exclude-functions: diff --git a/README.md b/README.md index 6b571c4..585ff8e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Consul Exporter -[![CircleCI](https://circleci.com/gh/prometheus/consul_exporter/tree/master.svg?style=shield)][circleci] +[![Build Status](https://github.com/prometheus/consul_exporter/actions/workflows/ci.yml/badge.svg)](https://github.com/prometheus/consul_exporter/actions/workflows/ci.yml) [![Docker Repository on Quay](https://quay.io/repository/prometheus/consul-exporter/status)][quay] [![Docker Pulls](https://img.shields.io/docker/pulls/prom/consul-exporter.svg?maxAge=604800)][hub] @@ -133,6 +133,5 @@ To use TLS and/or basic authentication, you need to pass a configuration file using the `--web.config.file` parameter. The format of the file is described [in the exporter-toolkit repository](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md). -[circleci]: https://circleci.com/gh/prometheus/consul_exporter [hub]: https://hub.docker.com/r/prom/consul-exporter/ [quay]: https://quay.io/repository/prometheus/consul-exporter diff --git a/cmd/consul_exporter/consul_exporter.go b/cmd/consul_exporter/consul_exporter.go index 5ef2ce3..88ea7e0 100644 --- a/cmd/consul_exporter/consul_exporter.go +++ b/cmd/consul_exporter/consul_exporter.go @@ -89,7 +89,7 @@ func main() { } prometheus.MustRegister(exporter) - queryOptionsJson, err := json.MarshalIndent(queryOptions, "", " ") + queryOptionsJSON, err := json.MarshalIndent(queryOptions, "", " ") if err != nil { logger.Error("Error marshaling query options", "err", err) os.Exit(1) @@ -108,25 +108,25 @@ func main() { ), ), ) - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Write([]byte(` Consul Exporter

Consul Exporter

Metrics

Options

-
` + string(queryOptionsJson) + `
+
` + string(queryOptionsJSON) + `

Build

` + version.Info() + ` ` + version.BuildContext() + `
`)) }) - http.HandleFunc("/-/healthy", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/-/healthy", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "OK") }) - http.HandleFunc("/-/ready", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/-/ready", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "OK") }) diff --git a/pkg/exporter/consul_exporter.go b/pkg/exporter/consul_exporter.go index 7eb10c6..69d502e 100644 --- a/pkg/exporter/consul_exporter.go +++ b/pkg/exporter/consul_exporter.go @@ -17,7 +17,6 @@ import ( "fmt" "log/slog" "net/http" - _ "net/http/pprof" "net/url" "regexp" "strconv"