cleanup(all): stop using deprecated ioutil functions (#381)

Spotted while working on https://github.com/ooni/probe/issues/1417

See https://golang.org/pkg/io/ioutil/
This commit is contained in:
Simone Basso
2021-06-15 14:01:45 +02:00
committed by GitHub
parent 721ce95315
commit fd5405ade1
25 changed files with 64 additions and 72 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ package config
import (
"encoding/json"
"io/ioutil"
"os"
"sync"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/utils"
@@ -14,7 +14,7 @@ const ConfigVersion = 1
// ReadConfig reads the configuration from the path
func ReadConfig(path string) (*Config, error) {
b, err := ioutil.ReadFile(path)
b, err := os.ReadFile(path)
if err != nil {
return nil, err
}
@@ -67,7 +67,7 @@ func (c *Config) Write() error {
if c.path == "" {
return errors.New("config file path is empty")
}
if err := ioutil.WriteFile(c.path, configJSON, 0644); err != nil {
if err := os.WriteFile(c.path, configJSON, 0644); err != nil {
return errors.Wrap(err, "writing config JSON")
}
return nil
+2 -2
View File
@@ -43,11 +43,11 @@ func TestUpdateConfig(t *testing.T) {
configPath := tmpFile.Name()
defer os.Remove(configPath)
data, err := ioutil.ReadFile("testdata/config-v0.json")
data, err := os.ReadFile("testdata/config-v0.json")
if err != nil {
t.Error(err)
}
err = ioutil.WriteFile(configPath, data, 0644)
err = os.WriteFile(configPath, data, 0644)
if err != nil {
t.Error(err)
}