Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
tufitko committed Feb 8, 2022
1 parent 119c039 commit 7aa1971
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ func CanReadCertAndKey(certPath, keyPath string) (bool, error) {
certReadable := canReadFile(certPath)
keyReadable := canReadFile(keyPath)

if certReadable == false && keyReadable == false {
if !certReadable && !keyReadable {
return false, nil
}

if certReadable == false {
if !certReadable {
return false, fmt.Errorf("error reading %s, certificate and key must be supplied as a pair", certPath)
}

if keyReadable == false {
if !keyReadable {
return false, fmt.Errorf("error reading %s, certificate and key must be supplied as a pair", keyPath)
}

Expand Down Expand Up @@ -172,6 +172,9 @@ func NewExporter(opts kafkaOpts, topicFilter string, groupFilter string) (*Expor

if opts.useZooKeeperLag {
zookeeperClient, err = kazoo.NewKazoo(opts.uriZookeeper, nil)
if err != nil {
panic(err)
}
}

interval, err := time.ParseDuration(opts.metadataRefreshInterval)
Expand Down Expand Up @@ -242,14 +245,8 @@ func (e *Exporter) backgroundCollect(interval time.Duration) {
ms := make([]prometheus.Metric, 0)
ch := make(chan prometheus.Metric)
go func() {
for {
select {
case m, ok := <-ch:
if !ok {
return
}
ms = append(ms, m)
}
for m := range ch {
ms = append(ms, m)
}
}()

Expand Down Expand Up @@ -661,13 +658,16 @@ func main() {

http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
_, err := w.Write([]byte(`<html>
<head><title>Kafka Exporter</title></head>
<body>
<h1>Kafka Exporter</h1>
<p><a href='` + *metricsPath + `'>Metrics</a></p>
</body>
</html>`))
if err != nil {
plog.Error(err.Error())
}
})

plog.Infoln("Listening on", *listenAddress)
Expand Down

0 comments on commit 7aa1971

Please sign in to comment.