diff --git a/api/robeaux/robeaux.go b/api/robeaux/robeaux.go index 709526eb..59b5242b 100644 --- a/api/robeaux/robeaux.go +++ b/api/robeaux/robeaux.go @@ -45,7 +45,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -1014,7 +1013,7 @@ func RestoreAsset(dir, name string) error { if err != nil { return err } - err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + err = os.WriteFile(_filePath(dir, name), data, info.Mode()) if err != nil { return err } diff --git a/examples/bebop_ps3_video.go b/examples/bebop_ps3_video.go index 4f31f373..74b38b67 100644 --- a/examples/bebop_ps3_video.go +++ b/examples/bebop_ps3_video.go @@ -30,7 +30,6 @@ package main import ( "fmt" "io" - "io/ioutil" "os/exec" "sync/atomic" "time" @@ -70,7 +69,7 @@ func ffmpeg() (stdin io.WriteCloser, stderr io.ReadCloser, err error) { go func() { for { - buf, err := ioutil.ReadAll(stderr) + buf, err := io.ReadAll(stderr) if err != nil { fmt.Println(err) } diff --git a/examples/firmata_travis.go b/examples/firmata_travis.go index 4c836d2a..970f9c8a 100644 --- a/examples/firmata_travis.go +++ b/examples/firmata_travis.go @@ -16,7 +16,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "time" @@ -63,7 +63,7 @@ func checkTravis(robot *gobot.Robot) { panic(err) } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { panic(err) } diff --git a/platforms/chip/chip_adaptor.go b/platforms/chip/chip_adaptor.go index fc6acfc8..4cc9eda5 100644 --- a/platforms/chip/chip_adaptor.go +++ b/platforms/chip/chip_adaptor.go @@ -2,7 +2,7 @@ package chip import ( "fmt" - "io/ioutil" + "os" "path/filepath" "strconv" "strings" @@ -119,14 +119,14 @@ func getXIOBase() (baseAddr int, err error) { } for _, labelPath := range labels { - label, err := ioutil.ReadFile(labelPath) + label, err := os.ReadFile(labelPath) if err != nil { return baseAddr, err } if strings.HasPrefix(string(label), expanderID) { expanderPath, _ := filepath.Split(labelPath) basePath := filepath.Join(expanderPath, "base") - base, err := ioutil.ReadFile(basePath) + base, err := os.ReadFile(basePath) if err != nil { return baseAddr, err } diff --git a/platforms/joystick/joystick_driver.go b/platforms/joystick/joystick_driver.go index 85c91c38..d473bfad 100644 --- a/platforms/joystick/joystick_driver.go +++ b/platforms/joystick/joystick_driver.go @@ -3,7 +3,7 @@ package joystick import ( "encoding/json" "fmt" - "io/ioutil" + "os" "time" "github.com/veandco/go-sdl2/sdl" @@ -250,7 +250,7 @@ func (j *Driver) findHatName(id uint8, hat uint8, list []hat) string { // loadFile load the joystick config from a .json file func (j *Driver) loadFile() error { - file, e := ioutil.ReadFile(j.configPath) + file, e := os.ReadFile(j.configPath) if e != nil { return e } diff --git a/platforms/leap/leap_motion_driver_test.go b/platforms/leap/leap_motion_driver_test.go index e98d080b..90267ac9 100644 --- a/platforms/leap/leap_motion_driver_test.go +++ b/platforms/leap/leap_motion_driver_test.go @@ -3,7 +3,7 @@ package leap import ( "errors" "io" - "io/ioutil" + "os" "strings" "sync" "testing" @@ -47,7 +47,7 @@ func initTestLeapMotionDriver() (*Driver, *NullReadWriteCloser) { d := NewDriver(a) d.receive = func(ws io.ReadWriteCloser, buf *[]byte) { - file, _ := ioutil.ReadFile("./test/support/example_frame.json") + file, _ := os.ReadFile("./test/support/example_frame.json") copy(*buf, file) } return d, rwc @@ -82,7 +82,7 @@ func TestLeapMotionDriverHalt(t *testing.T) { func TestLeapMotionDriverParser(t *testing.T) { d, _ := initTestLeapMotionDriver() - file, _ := ioutil.ReadFile("./test/support/example_frame.json") + file, _ := os.ReadFile("./test/support/example_frame.json") parsedFrame := d.ParseFrame(file) if parsedFrame.Hands == nil || parsedFrame.Pointables == nil || parsedFrame.Gestures == nil { diff --git a/platforms/mqtt/mqtt_adaptor.go b/platforms/mqtt/mqtt_adaptor.go index 3056ab7d..9268f2b9 100644 --- a/platforms/mqtt/mqtt_adaptor.go +++ b/platforms/mqtt/mqtt_adaptor.go @@ -3,7 +3,7 @@ package mqtt import ( "crypto/tls" "crypto/x509" - "io/ioutil" + "os" "gobot.io/x/gobot/v2" @@ -204,7 +204,7 @@ func (a *Adaptor) newTLSConfig() *tls.Config { var certpool *x509.CertPool if len(a.ServerCert()) > 0 { certpool = x509.NewCertPool() - pemCerts, err := ioutil.ReadFile(a.ServerCert()) + pemCerts, err := os.ReadFile(a.ServerCert()) if err == nil { certpool.AppendCertsFromPEM(pemCerts) } diff --git a/platforms/parrot/bebop/client/examples/video.go b/platforms/parrot/bebop/client/examples/video.go index f9d0934a..3946c42c 100644 --- a/platforms/parrot/bebop/client/examples/video.go +++ b/platforms/parrot/bebop/client/examples/video.go @@ -25,7 +25,7 @@ package main import ( "fmt" - "io/ioutil" + "io" "os/exec" "time" @@ -73,7 +73,7 @@ func main() { go func() { for { - buf, err := ioutil.ReadAll(ffmpegErr) + buf, err := io.ReadAll(ffmpegErr) if err != nil { fmt.Println(err) } diff --git a/platforms/particle/adaptor.go b/platforms/particle/adaptor.go index a291efca..aed5da0d 100644 --- a/platforms/particle/adaptor.go +++ b/platforms/particle/adaptor.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -262,7 +262,7 @@ func (s *Adaptor) request(method string, url string, params url.Values) (m map[s return } - buf, err := ioutil.ReadAll(resp.Body) + buf, err := io.ReadAll(resp.Body) if err != nil { return diff --git a/system/fs_mock.go b/system/fs_mock.go index 5577fb84..197bad02 100644 --- a/system/fs_mock.go +++ b/system/fs_mock.go @@ -2,7 +2,6 @@ package system import ( "fmt" - "io/ioutil" "os" "path" "regexp" @@ -135,7 +134,7 @@ func (fs *MockFilesystem) stat(name string) (os.FileInfo, error) { _, ok := fs.Files[name] if ok { // return file based mock FileInfo - tmpFile, err := ioutil.TempFile("", name) + tmpFile, err := os.CreateTemp("", name) if err != nil { return nil, err } @@ -148,7 +147,7 @@ func (fs *MockFilesystem) stat(name string) (os.FileInfo, error) { for path := range fs.Files { if strings.HasPrefix(path, dirName) { // return dir based mock FileInfo, TempDir don't like "/" in between - tmpDir, err := ioutil.TempDir("", strings.ReplaceAll(name, "/", "_")) + tmpDir, err := os.MkdirTemp("", strings.ReplaceAll(name, "/", "_")) if err != nil { return nil, err }