Skip to content

Commit

Permalink
Switch from deprecated io/ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Jul 11, 2022
1 parent a9b05c5 commit 70d9bb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -25,7 +24,7 @@ func exportUpstart(cfg *config, path string) error {
if err != nil {
return err
}
b, err := ioutil.ReadFile(filepath.Join(filepath.Dir(procfile), ".env"))
b, err := os.ReadFile(filepath.Join(filepath.Dir(procfile), ".env"))
if err == nil {
for _, line := range strings.Split(string(b), "\n") {
token := strings.SplitN(line, "=", 2)
Expand Down
7 changes: 3 additions & 4 deletions goreman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -23,13 +22,13 @@ func TestMain(m *testing.M) {
}

code := `package main;import ("os";"strconv";"time");func main(){i,_:=strconv.ParseFloat(os.Args[1]);time.Sleep(time.Duration(i)*time.Second)}`
dir, err := ioutil.TempDir("", "goreman-test")
dir, err := os.MkdirTemp("", "goreman-test")
if err != nil {
panic(err)
}
sleep = filepath.Join(dir, "sleep.exe")
src := filepath.Join(dir, "sleep.go")
err = ioutil.WriteFile(src, []byte(code), 0644)
err = os.WriteFile(src, []byte(code), 0644)
if err != nil {
panic(err)
}
Expand All @@ -51,7 +50,7 @@ func TestMain(m *testing.M) {

func startGoreman(ctx context.Context, t *testing.T, ch <-chan os.Signal, file []byte) error {
t.Helper()
f, err := ioutil.TempFile("", "")
f, err := os.CreateTemp("", "")
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"regexp"
Expand Down Expand Up @@ -129,7 +128,7 @@ func readConfig() *config {
cfg.ExitOnError = *exitOnError
cfg.Args = flag.Args()

b, err := ioutil.ReadFile(".goreman")
b, err := os.ReadFile(".goreman")
if err == nil {
yaml.Unmarshal(b, &cfg)
}
Expand All @@ -138,7 +137,7 @@ func readConfig() *config {

// read Procfile and parse it.
func readProcfile(cfg *config) error {
content, err := ioutil.ReadFile(cfg.Procfile)
content, err := os.ReadFile(cfg.Procfile)
if err != nil {
return err
}
Expand Down

0 comments on commit 70d9bb6

Please sign in to comment.