Skip to content

Commit

Permalink
Merge pull request #50 from testwill/ioutil
Browse files Browse the repository at this point in the history
chore: remove refs to deprecated io/ioutil
  • Loading branch information
enc authored Apr 12, 2024
2 parents b478b86 + 2063252 commit 289fb48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions envplate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package envplate

import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -61,7 +60,7 @@ func (h *Handler) Apply(globs []string) error {
func (h *Handler) parse(file string) error {

env := envmap.Import()
content, err := ioutil.ReadFile(file)
content, err := os.ReadFile(file)

if err != nil {
return Log(ERROR, "Cannot open %s: %v", file, err)
Expand Down Expand Up @@ -138,7 +137,7 @@ func (h *Handler) parse(file string) error {
return err
}

if err := ioutil.WriteFile(file, []byte(parsed), mode); err != nil {
if err := os.WriteFile(file, []byte(parsed), mode); err != nil {
return err
}

Expand Down
7 changes: 3 additions & 4 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"testing"
Expand All @@ -25,7 +24,7 @@ func _exists(name string) bool {

func _read(t *testing.T, name string) string {

content, err := ioutil.ReadFile(name)
content, err := os.ReadFile(name)

if err != nil {
t.Fatal(fmt.Errorf("error while reading '%s': %v", name, err))
Expand Down Expand Up @@ -82,7 +81,7 @@ func _restore(file string) {

func _tmpdir(t *testing.T, f func(string)) {

dir, err := ioutil.TempDir("", "")
dir, err := os.MkdirTemp("", "")

if err != nil {
t.Fatal(err)
Expand All @@ -96,7 +95,7 @@ func _tmpdir(t *testing.T, f func(string)) {

func _write(t *testing.T, name, content string, mode os.FileMode) string {

file, err := ioutil.TempFile("", name)
file, err := os.CreateTemp("", name)

if err != nil {
t.Fatalf("Error while opening '%s': %v", name, err)
Expand Down

0 comments on commit 289fb48

Please sign in to comment.