Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
  • Loading branch information
Caleb Lloyd committed Jan 20, 2023
1 parent 8f40861 commit bf2a1dd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ _test
*.[568vq]
[568vq].out

# IDE
.idea

*.cgo1.go
*.cgo2.c
_cgo_defun.c
Expand Down
6 changes: 3 additions & 3 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package collector

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strings"
"sync"
Expand Down Expand Up @@ -112,7 +112,7 @@ func getMetricURL(httpClient *http.Client, url string, response interface{}) err
return err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand All @@ -128,7 +128,7 @@ func GetServerIDFromVarz(endpoint string, retryInterval time.Duration) string {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion collector/jsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader)
}

var isJetStreamDisabled float64 = 0
var isJetStreamDisabled float64
if resp.Disabled {
isJetStreamDisabled = 1
}
Expand Down
5 changes: 2 additions & 3 deletions collector/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package collector

import (
"fmt"
"io/ioutil"
"os"
"testing"
)
Expand Down Expand Up @@ -72,15 +71,15 @@ func TestLogging(t *testing.T) {
// ConfigureLogger(sOpts, nOpts)

// test file
tmpDir, err := ioutil.TempDir("", "_exporter")
tmpDir, err := os.MkdirTemp("", "_exporter")
if err != nil {
t.Fatal("Could not create tmp dir")
}
defer func() {
_ = os.RemoveAll(tmpDir)
}()

file, err := ioutil.TempFile(tmpDir, "exporter:log_")
file, err := os.CreateTemp(tmpDir, "exporter:log_")
if err != nil {
t.Fatalf("unable to create temporary file")
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"crypto/x509"
"encoding/base64"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -276,7 +276,7 @@ func (ne *NATSExporter) generateTLSConfig() (*tls.Config, error) {
}
// Add in CAs if applicable.
if ne.opts.CaFile != "" {
rootPEM, err := ioutil.ReadFile(ne.opts.CaFile)
rootPEM, err := os.ReadFile(ne.opts.CaFile)
if err != nil || rootPEM == nil {
return nil, fmt.Errorf("failed to load root ca certificate (%s): %v", ne.opts.CaFile, err)
}
Expand Down
7 changes: 4 additions & 3 deletions exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -52,7 +53,7 @@ func getStaticExporterTestOptions() (opts *NATSExporterOptions) {

func httpGetSecure(url string) (*http.Response, error) {
tlsConfig := &tls.Config{}
caCert, err := ioutil.ReadFile(caCertFile)
caCert, err := os.ReadFile(caCertFile)
if err != nil {
return nil, fmt.Errorf("Got error reading RootCA file: %s", err)
}
Expand Down Expand Up @@ -113,7 +114,7 @@ func checkExporterFull(user, pass, addr, result, path string, secure bool, expec
return "", nil
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("got an error reading the body: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// prometheus-nats-exporter
package main

import (
Expand Down
3 changes: 1 addition & 2 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package test

import (
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -176,7 +175,7 @@ func RunJetStreamServerWithPorts(port, monitorPort int, domain string) *server.S
opts.Port = port
opts.JetStream = true
opts.JetStreamDomain = domain
tdir, _ := ioutil.TempDir(tempRoot, "js-storedir-")
tdir, _ := os.MkdirTemp(tempRoot, "js-storedir-")
opts.StoreDir = filepath.Dir(tdir)
opts.HTTPHost = "127.0.0.1"
opts.HTTPPort = monitorPort
Expand Down

0 comments on commit bf2a1dd

Please sign in to comment.