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

Replaced deprecated io/ioutil package #41

Merged
merged 1 commit into from
Dec 2, 2023
Merged
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
3 changes: 1 addition & 2 deletions pkg/boilr/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package boilr
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -104,7 +103,7 @@ func init() {
return
}

buf, err := ioutil.ReadFile(Configuration.FilePath)
buf, err := os.ReadFile(Configuration.FilePath)
if err != nil {
exit.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -83,7 +82,7 @@ var Use = &cli.Command{
return fmt.Errorf("use: parent directory %q doesn't exist", parentDir)
}

tmpDir, err := ioutil.TempDir("", "boilr-use-template")
tmpDir, err := os.MkdirTemp("", "boilr-use-template")
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/cmd/use_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -11,9 +10,9 @@ import (

func TestUseExecutesProjectTemplate(t *testing.T) {
t.SkipNow()
tmpDirPath, err := ioutil.TempDir("", "template-test")
tmpDirPath, err := os.MkdirTemp("", "template-test")
if err != nil {
t.Fatalf("ioutil.TempDir() got error -> %v", err)
t.Fatalf("os.MkdirTemp() got error -> %v", err)
}
// else {
// defer os.RemoveAll(tmpDirPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/util/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package util
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -70,7 +69,7 @@ func ValidateArgs(args []string, validations []validate.Argument) error {
}

func testTemplate(path string) error {
tmpDir, err := ioutil.TempDir("", "boilr-validation-test")
tmpDir, err := os.MkdirTemp("", "boilr-validation-test")
if err != nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -57,7 +56,7 @@ func Get(path string) (Interface, error) {
}
defer f.Close()

buf, err := ioutil.ReadAll(f)
buf, err := io.ReadAll(f)
if err != nil {
return nil, err
}
Expand All @@ -83,7 +82,7 @@ func Get(path string) (Interface, error) {
return Metadata{}, nil
}

b, err := ioutil.ReadFile(filepath.Join(absPath, boilr.TemplateMetadataName))
b, err := os.ReadFile(filepath.Join(absPath, boilr.TemplateMetadataName))
if err != nil {
return Metadata{}, err
}
Expand Down Expand Up @@ -217,7 +216,7 @@ func (t *dirTemplate) Execute(dirPrefix string) error {
}

defer func(fname string) {
contents, err := ioutil.ReadFile(fname)
contents, err := os.ReadFile(fname)
if err != nil {
tlog.Debug(fmt.Sprintf("couldn't read the contents of file %q, got error %q", fname, err))
return
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/exec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package exec
import (
"errors"
"fmt"
"io/ioutil"
"io"
"os/exec"
)

Expand All @@ -28,13 +28,13 @@ func Cmd(executable string, args ...string) (string, error) {
return "", err
}

outBuf, err := ioutil.ReadAll(stdout)
outBuf, err := io.ReadAll(stdout)
if err != nil {
return "", err
}
out := string(outBuf)

errBuf, err := ioutil.ReadAll(stderr)
errBuf, err := io.ReadAll(stderr)
if err != nil {
fmt.Println(errBuf)
return "", err
Expand Down