This commit is contained in:
my-git9 2023-10-02 20:44:47 -07:00 committed by GitHub
commit ef8a7df515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 15 deletions

View File

@ -16,7 +16,7 @@ package dbtester
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -57,7 +57,7 @@ type Config struct {
// ReadConfig reads control configuration file.
func ReadConfig(fpath string, analyze bool) (*Config, error) {
bts, err := ioutil.ReadFile(fpath)
bts, err := os.ReadFile(fpath)
if err != nil {
return nil, err
}
@ -279,7 +279,7 @@ func ReadConfig(fpath string, analyze bool) (*Config, error) {
}
if cfg.ConfigClientMachineInitial.GoogleCloudStorageKeyPath != "" && !analyze {
bts, err = ioutil.ReadFile(cfg.ConfigClientMachineInitial.GoogleCloudStorageKeyPath)
bts, err = os.ReadFile(cfg.ConfigClientMachineInitial.GoogleCloudStorageKeyPath)
if err != nil {
return nil, err
}

View File

@ -17,7 +17,6 @@ package fileinspect
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -45,7 +44,7 @@ func writeData(fpath string, data []byte) (n int, err error) {
}
func createData() (dir string, n int64, err error) {
dir, err = ioutil.TempDir(os.TempDir(), "fileinspect-write-test")
dir, err = os.MkdirTemp(os.TempDir(), "fileinspect-write-test")
if err != nil {
return
}

View File

@ -15,8 +15,8 @@
package main
import (
"io/ioutil"
"log"
"os"
"github.com/etcd-io/dbtester/pkg/remotestorage"
@ -24,7 +24,7 @@ import (
)
func main() {
kbs, err := ioutil.ReadFile("key.json")
kbs, err := os.ReadFile("key.json")
if err != nil {
log.Fatal(err)
}
@ -37,7 +37,7 @@ func main() {
}
// upload directories
// kbs, err := ioutil.ReadFile("key.json")
// kbs, err := os.ReadFile("key.json")
// if err != nil {
// log.Fatal(err)
// }

View File

@ -17,7 +17,7 @@ package remotestorage
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -91,9 +91,9 @@ func (g *GoogleCloudStorage) UploadFile(bucket, src, dst string, opts ...OpOptio
}
g.lg.Info("uploading", zap.String("source", src), zap.String("destination", dst))
bts, err := ioutil.ReadFile(src)
bts, err := os.ReadFile(src)
if err != nil {
return fmt.Errorf("ioutil.ReadFile(%s) %v", src, err)
return fmt.Errorf("os.ReadFile(%s) %v", src, err)
}
if _, err := wc.Write(bts); err != nil {
return err
@ -144,9 +144,9 @@ func (g *GoogleCloudStorage) UploadDir(bucket, src, dst string, opts ...OpOption
if ret.ContentType != "" {
wc.ContentType = ret.ContentType
}
bts, err := ioutil.ReadFile(fpath)
bts, err := os.ReadFile(fpath)
if err != nil {
errc <- fmt.Errorf("ioutil.ReadFile(%s) %v", fpath, err)
errc <- fmt.Errorf("os.ReadFile(%s) %v", fpath, err)
return
}
if _, err := wc.Write(bts); err != nil {

View File

@ -17,7 +17,6 @@ package dbtester
import (
"fmt"
"io"
"io/ioutil"
mrand "math/rand"
"net/http"
"os"
@ -90,7 +89,7 @@ func exist(fpath string) bool {
// and closes it. This prevents TCP/TLS connections from closing,
// therefore available for reuse.
func gracefulClose(resp *http.Response) {
io.Copy(ioutil.Discard, resp.Body)
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}