Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: change package ioutil->os #923

Merged
merged 4 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/robeaux/robeaux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions cli/generate.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file was removed now, please rebase your branch (or simply revert the change on this file)

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"strings"
"text/template"
Expand Down Expand Up @@ -149,7 +148,7 @@ func generatePlatform(c config) error {

c.dir = dir

exp, err := ioutil.ReadFile(exampleDir + "/main.go")
exp, err := os.ReadFile(exampleDir + "/main.go")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions examples/bebop_ps3_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"os/exec"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/firmata_travis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/chip/chip_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package chip

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions platforms/joystick/joystick_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package joystick
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"time"

"github.com/veandco/go-sdl2/sdl"
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/leap/leap_motion_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package leap
import (
"errors"
"io"
"io/ioutil"
"os"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions platforms/mqtt/mqtt_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mqtt
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"os"

"gobot.io/x/gobot/v2"

Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions platforms/parrot/bebop/client/examples/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"os/exec"
"time"

Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions platforms/particle/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions system/fs_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package system

import (
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down