fix: remove deprecated ioutil and rand calls

- Change ioutil to io and os calls per Go 1.16 deprecation
- Move global random to localized random source
This commit is contained in:
Tyler Davis
2023-02-21 20:19:36 +00:00
committed by Ben Johnson
parent 6bbced3d46
commit 91e57a6156
6 changed files with 15 additions and 19 deletions

View File

@@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/url"
"os"
@@ -253,7 +252,7 @@ func readConfigFile(filename string, expandEnv bool) (_ Config, err error) {
// Read configuration.
// Do not return an error if using default path and file is missing.
buf, err := ioutil.ReadFile(filename)
buf, err := os.ReadFile(filename)
if err != nil {
return config, err
}

View File

@@ -3,7 +3,6 @@ package main_test
import (
"bytes"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -23,7 +22,7 @@ func TestReadConfigFile(t *testing.T) {
// Ensure global AWS settings are propagated down to replica configurations.
t.Run("PropagateGlobalSettings", func(t *testing.T) {
filename := filepath.Join(t.TempDir(), "litestream.yml")
if err := ioutil.WriteFile(filename, []byte(`
if err := os.WriteFile(filename, []byte(`
access-key-id: XXX
secret-access-key: YYY
@@ -55,7 +54,7 @@ dbs:
os.Setenv("LITESTREAM_TEST_1872363", "s3://foo/bar")
filename := filepath.Join(t.TempDir(), "litestream.yml")
if err := ioutil.WriteFile(filename, []byte(`
if err := os.WriteFile(filename, []byte(`
dbs:
- path: $LITESTREAM_TEST_0129380
replicas:
@@ -82,7 +81,7 @@ dbs:
os.Setenv("LITESTREAM_TEST_9847533", "s3://foo/bar")
filename := filepath.Join(t.TempDir(), "litestream.yml")
if err := ioutil.WriteFile(filename, []byte(`
if err := os.WriteFile(filename, []byte(`
dbs:
- path: /path/to/db
replicas: