fix: use of ioutil package (#5261)

* fix ioutil.NopCloser

* fix ioutil.ReadAll

* fix ioutil.ReadFile

* fix ioutil.WriteFile

* run goimports -w -format-only ./

* update CHANGELOG.md
This commit is contained in:
Kota
2023-06-25 19:48:23 +09:00
committed by GitHub
parent a04bf251c7
commit 6f803ec9a9
26 changed files with 73 additions and 85 deletions

View File

@@ -19,7 +19,6 @@ package env
import (
"fmt"
"go/build"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -119,7 +118,7 @@ func GetRuntimeEnv(key string) (string, error) {
}
var runtimeEnv string
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return "", err
}

View File

@@ -20,7 +20,6 @@ import (
"context"
"errors"
"io"
"io/ioutil"
"os"
"os/user"
"path/filepath"
@@ -54,7 +53,7 @@ func (ini *IniConfig) Parse(name string) (Configer, error) {
}
func (ini *IniConfig) parseFile(name string) (*IniConfigContainer, error) {
data, err := ioutil.ReadFile(name)
data, err := os.ReadFile(name)
if err != nil {
return nil, err
}

View File

@@ -16,7 +16,6 @@ package config
import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
@@ -173,7 +172,7 @@ name=mysql
}
defer os.Remove(name)
if data, err := ioutil.ReadFile(name); err != nil {
if data, err := os.ReadFile(name); err != nil {
t.Fatal(err)
} else {
cfgData := string(data)

View File

@@ -18,7 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"os"
"strconv"
"strings"
@@ -40,7 +40,7 @@ func (js *JSONConfig) Parse(filename string) (config.Configer, error) {
return nil, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return nil, err
}

View File

@@ -15,7 +15,6 @@
package toml
import (
"io/ioutil"
"os"
"strings"
@@ -32,7 +31,7 @@ type Config struct {
// Parse accepts filename as the parameter
func (c *Config) Parse(filename string) (config.Configer, error) {
ctx, err := ioutil.ReadFile(filename)
ctx, err := os.ReadFile(filename)
if err != nil {
return nil, err
}

View File

@@ -32,7 +32,6 @@ import (
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
@@ -53,7 +52,7 @@ type Config struct{}
// Parse returns a ConfigContainer with parsed xml config map.
func (xc *Config) Parse(filename string) (config.Configer, error) {
context, err := ioutil.ReadFile(filename)
context, err := os.ReadFile(filename)
if err != nil {
return nil, err
}

View File

@@ -26,7 +26,6 @@ package yaml
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"sync"
@@ -66,7 +65,7 @@ func (*Config) ParseData(data []byte) (config.Configer, error) {
// ReadYmlReader Read yaml file to map.
func ReadYmlReader(path string) (cnf map[string]interface{}, err error) {
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
return
}