Skip to content

Commit d286b88

Browse files
authored
Merge pull request #172 from ardevd/replace-ioutil-calls
refactor: replaced deprecated ioutil calls with os equivalents
2 parents 05065f4 + dacaa68 commit d286b88

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

basic_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package lndclient
33
import (
44
"encoding/hex"
55
"fmt"
6-
"io/ioutil"
6+
"os"
77
"path/filepath"
88

99
"github.com/lightningnetwork/lnd/lncfg"
@@ -184,7 +184,7 @@ func parseTLSAndMacaroon(tlsPath, macDir, network string,
184184
macPath := filepath.Join(macDir, bco.macFilename)
185185

186186
// Load the specified macaroon file.
187-
macBytes, err = ioutil.ReadFile(macPath)
187+
macBytes, err = os.ReadFile(macPath)
188188
if err != nil {
189189
return nil, nil, err
190190
}

basic_client_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package lndclient
22

33
import (
44
"encoding/hex"
5-
"io/ioutil"
65
"os"
76
"testing"
87

@@ -46,21 +45,19 @@ XhkpT5dliEGFLNe6OOgeWTU1JpEXfCud/GImtNMHQi4EDWQfvWuCNGhOoQ==
4645

4746
// Now let's write the data to a file to make sure parseTLSAndMacaroon
4847
// parses that properly as well.
49-
tempDirPath, err := ioutil.TempDir("", ".testCreds")
50-
require.NoError(t, err)
51-
defer os.RemoveAll(tempDirPath)
48+
tempDirPath := t.TempDir()
5249

5350
certPath := tempDirPath + "/tls.cert"
5451
tlsPEMBytes := []byte(tlsData)
5552

56-
err = ioutil.WriteFile(certPath, tlsPEMBytes, 0644)
53+
err = os.WriteFile(certPath, tlsPEMBytes, 0644)
5754
require.NoError(t, err)
5855

5956
macPath := tempDirPath + "/test.macaroon"
6057
macBytes, err := hex.DecodeString(macData)
6158
require.NoError(t, err)
6259

63-
err = ioutil.WriteFile(macPath, macBytes, 0644)
60+
err = os.WriteFile(macPath, macBytes, 0644)
6461
require.NoError(t, err)
6562

6663
_, _, err = parseTLSAndMacaroon(

macaroon_pouch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package lndclient
33
import (
44
"context"
55
"encoding/hex"
6-
"io/ioutil"
6+
"os"
77
"path/filepath"
88

99
"google.golang.org/grpc/metadata"
@@ -64,7 +64,7 @@ type serializedMacaroon string
6464
// newSerializedMacaroon reads a new serializedMacaroon from that target
6565
// macaroon path. If the file can't be found, then an error is returned.
6666
func newSerializedMacaroon(macaroonPath string) (serializedMacaroon, error) {
67-
macBytes, err := ioutil.ReadFile(macaroonPath)
67+
macBytes, err := os.ReadFile(macaroonPath)
6868
if err != nil {
6969
return "", err
7070
}

macaroon_recipes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package lndclient_test
33
import (
44
"context"
55
"encoding/json"
6-
"io/ioutil"
6+
"os"
77
"testing"
88

99
"github.com/lightninglabs/lndclient"
@@ -48,7 +48,7 @@ func (m *lightningMock) ListPermissions(
4848
func TestMacaroonRecipe(t *testing.T) {
4949
// Load our static permissions exported from lnd by calling
5050
// `lncli listpermissions > permissions.json`.
51-
content, err := ioutil.ReadFile("testdata/permissions.json")
51+
content, err := os.ReadFile("testdata/permissions.json")
5252
require.NoError(t, err)
5353

5454
data := &permissionJSONData{}

0 commit comments

Comments
 (0)