mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-30 23:28:04 +08:00
Remove uses of deprecated io/ioutil
The package has been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutil Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -2,7 +2,6 @@ package store
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -46,7 +45,7 @@ type Txn struct {
|
||||
|
||||
func (t *Txn) List() ([]*NodeGroup, error) {
|
||||
pp := filepath.Join(t.s.root, "instances")
|
||||
fis, err := ioutil.ReadDir(pp)
|
||||
fis, err := os.ReadDir(pp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -75,7 +74,7 @@ func (t *Txn) NodeGroupByName(name string) (*NodeGroup, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dt, err := ioutil.ReadFile(filepath.Join(t.s.root, "instances", name))
|
||||
dt, err := os.ReadFile(filepath.Join(t.s.root, "instances", name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -144,7 +143,7 @@ func (t *Txn) reset(key string) error {
|
||||
}
|
||||
|
||||
func (t *Txn) Current(key string) (*NodeGroup, error) {
|
||||
dt, err := ioutil.ReadFile(filepath.Join(t.s.root, "current"))
|
||||
dt, err := os.ReadFile(filepath.Join(t.s.root, "current"))
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
@@ -175,7 +174,7 @@ func (t *Txn) Current(key string) (*NodeGroup, error) {
|
||||
|
||||
h := toHash(key)
|
||||
|
||||
dt, err = ioutil.ReadFile(filepath.Join(t.s.root, "defaults", h))
|
||||
dt, err = os.ReadFile(filepath.Join(t.s.root, "defaults", h))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
t.reset(key)
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
|
||||
func TestEmptyStartup(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpdir, err := ioutil.TempDir("", "buildx-store")
|
||||
tmpdir, err := os.MkdirTemp("", "buildx-store")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
@@ -30,7 +29,7 @@ func TestEmptyStartup(t *testing.T) {
|
||||
|
||||
func TestNodeLocking(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpdir, err := ioutil.TempDir("", "buildx-store")
|
||||
tmpdir, err := os.MkdirTemp("", "buildx-store")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
@@ -65,7 +64,7 @@ func TestNodeLocking(t *testing.T) {
|
||||
|
||||
func TestNodeManagement(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpdir, err := ioutil.TempDir("", "buildx-store")
|
||||
tmpdir, err := os.MkdirTemp("", "buildx-store")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
|
Reference in New Issue
Block a user