refactor: move from io/ioutil to io and os packages

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2021-11-25 12:09:23 +08:00
parent ae341be638
commit ef8d7d2fd7
26 changed files with 73 additions and 89 deletions

View File

@@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@@ -310,14 +309,14 @@ func (po *ProjectOptions) WriteProjectConfig() error {
return err
}
return ioutil.WriteFile(targetFile, filedata, 0600)
return os.WriteFile(targetFile, filedata, 0600)
}
// LoadConfig loads the project configuration file from the
// given directory
func (po *ProjectOptions) LoadConfig(projectDir string) error {
targetFile := filepath.Join(projectDir, "project.json")
rawBytes, err := ioutil.ReadFile(targetFile)
rawBytes, err := os.ReadFile(targetFile)
if err != nil {
return err
}