mirror of
https://github.com/lightninglabs/aperture.git
synced 2025-12-17 09:04:19 +01:00
lint: remove depreciated io/ioutil
As of Go 1.16, functionality provided in io/ioutil has been depreciated in favour of the io or os packages. Now that Go has been upgraded in go.mod, the linter will not pass without these changes.
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -414,7 +413,7 @@ func getConfig() (*Config, error) {
|
||||
|
||||
// Read our config file, either from the custom path provided or our
|
||||
// default location.
|
||||
b, err := ioutil.ReadFile(configFile)
|
||||
b, err := os.ReadFile(configFile)
|
||||
switch {
|
||||
// If the file was found, unmarshal it.
|
||||
case err == nil:
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -100,7 +99,7 @@ func (r *readStream) ReadNextMsg(ctx context.Context) ([]byte, error) {
|
||||
// reader, then read all the encoded bytes until the EOF is emitted by
|
||||
// the reader.
|
||||
msgReader := io.LimitReader(reader, int64(msgLen))
|
||||
return ioutil.ReadAll(msgReader)
|
||||
return io.ReadAll(msgReader)
|
||||
}
|
||||
|
||||
// ReturnStream gives up the read stream by passing it back up through the
|
||||
|
||||
@@ -3,7 +3,6 @@ package lsat
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -113,7 +112,7 @@ func (f *FileStore) AllTokens() (map[string]*Token, error) {
|
||||
// just one token, either pending or paid.
|
||||
// TODO(guggero): Update comment once tokens expire and we keep backups.
|
||||
tokenDir := filepath.Dir(f.fileName)
|
||||
files, err := ioutil.ReadDir(tokenDir)
|
||||
files, err := os.ReadDir(tokenDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -156,7 +155,7 @@ func (f *FileStore) StoreToken(newToken *Token) error {
|
||||
if newToken.isPending() {
|
||||
newFileName = f.fileNamePending
|
||||
}
|
||||
return ioutil.WriteFile(newFileName, bytes, 0600)
|
||||
return os.WriteFile(newFileName, bytes, 0600)
|
||||
|
||||
// Fail on any other error.
|
||||
case err != nil:
|
||||
@@ -173,7 +172,7 @@ func (f *FileStore) StoreToken(newToken *Token) error {
|
||||
|
||||
// Write the new token first, so we still have the pending
|
||||
// around if something goes wrong.
|
||||
err := ioutil.WriteFile(f.fileName, bytes, 0600)
|
||||
err := os.WriteFile(f.fileName, bytes, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -206,7 +205,7 @@ func (f *FileStore) RemovePendingToken() error {
|
||||
|
||||
// readTokenFile reads a single token from a file and returns it deserialized.
|
||||
func readTokenFile(tokenFile string) (*Token, error) {
|
||||
bytes, err := ioutil.ReadFile(tokenFile)
|
||||
bytes, err := os.ReadFile(tokenFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package lsat
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -13,7 +12,7 @@ import (
|
||||
func TestFileStore(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tempDirName, err := ioutil.TempDir("", "lsatstore")
|
||||
tempDirName, err := os.MkdirTemp("", "lsatstore")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -329,7 +329,7 @@ func certPool(services []*Service) (*x509.CertPool, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(service.TLSCertPath)
|
||||
b, err := os.ReadFile(service.TLSCertPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -169,7 +169,7 @@ func runHTTPTest(t *testing.T, tc *testCase) {
|
||||
|
||||
// Ensure that we got the response body we expect.
|
||||
defer closeOrFail(t, resp.Body)
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, testHTTPResponseBody, string(bodyBytes))
|
||||
@@ -188,7 +188,7 @@ func runHTTPTest(t *testing.T, tc *testCase) {
|
||||
|
||||
// Ensure that we got the response body we expect.
|
||||
defer closeOrFail(t, resp.Body)
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, testHTTPResponseBody, string(bodyBytes))
|
||||
@@ -237,7 +237,7 @@ func TestProxyGRPC(t *testing.T) {
|
||||
func runGRPCTest(t *testing.T, tc *testCase) {
|
||||
// Since gRPC only really works over TLS, we need to generate a
|
||||
// certificate and key pair first.
|
||||
tempDirName, err := ioutil.TempDir("", "proxytest")
|
||||
tempDirName, err := os.MkdirTemp("", "proxytest")
|
||||
require.NoError(t, err)
|
||||
certFile := path.Join(tempDirName, "proxy.cert")
|
||||
keyFile := path.Join(tempDirName, "proxy.key")
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -154,7 +154,7 @@ func prepareServices(services []*Service) error {
|
||||
"must be '!file+hex:path'")
|
||||
}
|
||||
prefix, fileName := parts[0], parts[1]
|
||||
bytes, err := ioutil.ReadFile(fileName)
|
||||
bytes, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -22,7 +21,7 @@ import (
|
||||
func etcdSetup(t *testing.T) (*clientv3.Client, func()) {
|
||||
t.Helper()
|
||||
|
||||
tempDir, err := ioutil.TempDir("", "etcd")
|
||||
tempDir, err := os.MkdirTemp("", "etcd")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create temp dir: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user