Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the 'os' and 'io' packages instead of the deperecated 'ioutil' package #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cmd/kaf/kaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -49,7 +48,7 @@ func getConfig() (saramaConfig *sarama.Config) {
}

if cluster.TLS.Cafile != "" {
caCert, err := ioutil.ReadFile(cluster.TLS.Cafile)
caCert, err := os.ReadFile(cluster.TLS.Cafile)
if err != nil {
errorExit("Unable to read Cafile :%v\n", err)
}
Expand All @@ -59,11 +58,11 @@ func getConfig() (saramaConfig *sarama.Config) {
}

if cluster.TLS.Clientfile != "" && cluster.TLS.Clientkeyfile != "" {
clientCert, err := ioutil.ReadFile(cluster.TLS.Clientfile)
clientCert, err := os.ReadFile(cluster.TLS.Clientfile)
if err != nil {
errorExit("Unable to read Clientfile :%v\n", err)
}
clientKey, err := ioutil.ReadFile(cluster.TLS.Clientkeyfile)
clientKey, err := os.ReadFile(cluster.TLS.Clientkeyfile)
if err != nil {
errorExit("Unable to read Clientkeyfile :%v\n", err)
}
Expand All @@ -86,7 +85,7 @@ func getConfig() (saramaConfig *sarama.Config) {
InsecureSkipVerify: cluster.TLS.Insecure,
}
if cluster.TLS.Cafile != "" {
caCert, err := ioutil.ReadFile(cluster.TLS.Cafile)
caCert, err := os.ReadFile(cluster.TLS.Cafile)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
3 changes: 1 addition & 2 deletions cmd/kaf/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"io"
"io/ioutil"
"os"
"testing"
"time"
Expand Down Expand Up @@ -54,7 +53,7 @@ func runCmd(t *testing.T, in io.Reader, args ...string) string {

require.NoError(t, rootCmd.ExecuteContext(ctx))

bs, err := ioutil.ReadAll(b)
bs, err := io.ReadAll(b)
require.NoError(t, err)

return string(bs)
Expand Down
5 changes: 2 additions & 3 deletions cmd/kaf/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"text/template"

"time"

"github.com/Masterminds/sprig"
"github.com/IBM/sarama"
"github.com/Masterminds/sprig"
"github.com/birdayz/kaf/pkg/partitioner"
pb "github.com/golang/protobuf/proto"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -79,7 +78,7 @@ func readLines(reader io.Reader, out chan []byte) {
}

func readFull(reader io.Reader, out chan []byte) {
data, err := ioutil.ReadAll(inReader)
data, err := io.ReadAll(inReader)
if err != nil {
errorExit("Unable to read data\n")
}
Expand Down