From c23688cebc94e1f4ba34027ce41ad5037b7ef053 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Thu, 9 May 2024 10:40:50 +0800 Subject: [PATCH] chore: remove refs to deprecated io/ioutil Signed-off-by: guoguangwu --- kafka_exporter.go | 5 ++--- simple_test.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/kafka_exporter.go b/kafka_exporter.go index 36021149..e9d871c0 100644 --- a/kafka_exporter.go +++ b/kafka_exporter.go @@ -5,7 +5,6 @@ import ( "crypto/x509" "flag" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -216,7 +215,7 @@ func NewExporter(opts kafkaOpts, topicFilter string, topicExclude string, groupF } if opts.tlsCAFile != "" { - if ca, err := ioutil.ReadFile(opts.tlsCAFile); err == nil { + if ca, err := os.ReadFile(opts.tlsCAFile); err == nil { config.Net.TLS.Config.RootCAs = x509.NewCertPool() config.Net.TLS.Config.RootCAs.AppendCertsFromPEM(ca) } else { @@ -939,7 +938,7 @@ func setup( certPool := x509.NewCertPool() if opts.serverTlsCAFile != "" { - if caCert, err := ioutil.ReadFile(opts.serverTlsCAFile); err == nil { + if caCert, err := os.ReadFile(opts.serverTlsCAFile); err == nil { certPool.AppendCertsFromPEM(caCert) } else { klog.Error("error reading server ca") diff --git a/simple_test.go b/simple_test.go index ae082df8..e87e0384 100644 --- a/simple_test.go +++ b/simple_test.go @@ -2,7 +2,7 @@ package main import ( "errors" - "io/ioutil" + "io" "log" "net/http" "testing" @@ -27,7 +27,7 @@ func TestSmoke(t *testing.T) { log.Println(resp.Status) defer resp.Body.Close() - bytes, err := ioutil.ReadAll(resp.Body) + bytes, err := io.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } else {