Skip to content

Commit 789c6ba

Browse files
committed
multi: replace ioutil.WriteFile
1 parent ab83343 commit 789c6ba

File tree

13 files changed

+20
-31
lines changed

13 files changed

+20
-31
lines changed

cert/selfsigned.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"crypto/x509/pkix"
1010
"encoding/pem"
1111
"fmt"
12-
"io/ioutil"
1312
"math/big"
1413
"net"
1514
"os"
@@ -295,14 +294,14 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string,
295294
func WriteCertPair(certFile, keyFile string, certBytes, keyBytes []byte) error {
296295
// Write cert and key files.
297296
if certFile != "" {
298-
err := ioutil.WriteFile(certFile, certBytes, 0644)
297+
err := os.WriteFile(certFile, certBytes, 0644)
299298
if err != nil {
300299
return err
301300
}
302301
}
303302

304303
if keyFile != "" {
305-
err := ioutil.WriteFile(keyFile, keyBytes, 0600)
304+
err := os.WriteFile(keyFile, keyBytes, 0600)
306305
if err != nil {
307306
os.Remove(certFile)
308307
return err

cmd/lncli/cmd_macaroon.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/hex"
66
"fmt"
7-
"io/ioutil"
87
"net"
98
"os"
109
"strconv"
@@ -193,7 +192,7 @@ func bakeMacaroon(ctx *cli.Context) error {
193192
// a file or write to the standard output using hex encoding.
194193
switch {
195194
case savePath != "":
196-
err = ioutil.WriteFile(savePath, macBytes, 0644)
195+
err = os.WriteFile(savePath, macBytes, 0644)
197196
if err != nil {
198197
return err
199198
}
@@ -472,7 +471,7 @@ func constrainMacaroon(ctx *cli.Context) error {
472471
}
473472

474473
// Now we can output the result.
475-
err = ioutil.WriteFile(destMacFile, destMacBytes, 0644)
474+
err = os.WriteFile(destMacFile, destMacBytes, 0644)
476475
if err != nil {
477476
return fmt.Errorf("error writing destination macaroon file "+
478477
"%s: %v", destMacFile, err)

cmd/lncli/profile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"io/ioutil"
109
"os"
1110
"path"
1211
"strings"
@@ -244,7 +243,8 @@ func saveProfileFile(file string, f *profileFile) error {
244243
if err != nil {
245244
return fmt.Errorf("could not marshal profile: %w", err)
246245
}
247-
return ioutil.WriteFile(file, content, 0644)
246+
247+
return os.WriteFile(file, content, 0644)
248248
}
249249

250250
// profileFile is a struct that represents the whole content of a profile file.

internal/musig2v040/musig2_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"errors"
1111
"flag"
1212
"fmt"
13-
"io/ioutil"
13+
"os"
1414
"sync"
1515
"testing"
1616

@@ -256,7 +256,7 @@ func TestMuSig2KeyAggTestVectors(t *testing.T) {
256256

257257
var formattedJson bytes.Buffer
258258
json.Indent(&formattedJson, jsonBytes, "", "\t")
259-
err = ioutil.WriteFile(
259+
err = os.WriteFile(
260260
keyAggTestVectorName, formattedJson.Bytes(), 0644,
261261
)
262262
if err != nil {
@@ -656,7 +656,7 @@ func TestMuSig2SigningTestVectors(t *testing.T) {
656656

657657
var formattedJson bytes.Buffer
658658
json.Indent(&formattedJson, jsonBytes, "", "\t")
659-
err = ioutil.WriteFile(
659+
err = os.WriteFile(
660660
signTestVectorName, formattedJson.Bytes(), 0644,
661661
)
662662
if err != nil {
@@ -1540,7 +1540,7 @@ func TestMusig2AggregateNoncesTestVectors(t *testing.T) {
15401540

15411541
var formattedJson bytes.Buffer
15421542
json.Indent(&formattedJson, jsonBytes, "", "\t")
1543-
err = ioutil.WriteFile(
1543+
err = os.WriteFile(
15441544
nonceAggTestVectorName, formattedJson.Bytes(), 0644,
15451545
)
15461546
if err != nil {

kvdb/backend.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"encoding/binary"
1010
"encoding/hex"
1111
"fmt"
12-
"io/ioutil"
1312
"os"
1413
"path/filepath"
1514
"time"
@@ -235,7 +234,7 @@ func updateLastCompactionDate(dbFile string) error {
235234
byteOrder.PutUint64(tsBytes[:], uint64(time.Now().UnixNano()))
236235

237236
tsFile := fmt.Sprintf("%s%s", dbFile, LastCompactionFileNameSuffix)
238-
return ioutil.WriteFile(tsFile, tsBytes[:], 0600)
237+
return os.WriteFile(tsFile, tsBytes[:], 0600)
239238
}
240239

241240
// GetTestBackend opens (or creates if doesn't exist) a bbolt or etcd

lnrpc/chainrpc/chain_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"bytes"
88
"context"
99
"errors"
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
"sync"
@@ -153,7 +152,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
153152
if err != nil {
154153
return nil, nil, err
155154
}
156-
err = ioutil.WriteFile(macFilePath, chainNotifierMacBytes, 0644)
155+
err = os.WriteFile(macFilePath, chainNotifierMacBytes, 0644)
157156
if err != nil {
158157
_ = os.Remove(macFilePath)
159158
return nil, nil, err

lnrpc/invoicesrpc/invoices_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"context"
88
"errors"
99
"fmt"
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312

@@ -132,7 +131,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
132131
if err != nil {
133132
return nil, nil, err
134133
}
135-
err = ioutil.WriteFile(macFilePath, invoicesMacBytes, 0644)
134+
err = os.WriteFile(macFilePath, invoicesMacBytes, 0644)
136135
if err != nil {
137136
_ = os.Remove(macFilePath)
138137
return nil, nil, err

lnrpc/routerrpc/router_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
crand "crypto/rand"
77
"errors"
88
"fmt"
9-
"io/ioutil"
109
"os"
1110
"path/filepath"
1211
"sync/atomic"
@@ -216,7 +215,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
216215
if err != nil {
217216
return nil, nil, err
218217
}
219-
err = ioutil.WriteFile(macFilePath, routerMacBytes, 0644)
218+
err = os.WriteFile(macFilePath, routerMacBytes, 0644)
220219
if err != nil {
221220
_ = os.Remove(macFilePath)
222221
return nil, nil, err

lnrpc/signrpc/signer_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"context"
99
"crypto/sha256"
1010
"fmt"
11-
"io/ioutil"
1211
"os"
1312
"path/filepath"
1413

@@ -167,7 +166,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
167166
if err != nil {
168167
return nil, nil, err
169168
}
170-
err = ioutil.WriteFile(macFilePath, signerMacBytes, 0644)
169+
err = os.WriteFile(macFilePath, signerMacBytes, 0644)
171170
if err != nil {
172171
_ = os.Remove(macFilePath)
173172
return nil, nil, err

lnrpc/walletrpc/walletkit_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/binary"
1111
"errors"
1212
"fmt"
13-
"io/ioutil"
1413
"math"
1514
"os"
1615
"path/filepath"
@@ -289,7 +288,7 @@ func New(cfg *Config) (*WalletKit, lnrpc.MacaroonPerms, error) {
289288
if err != nil {
290289
return nil, nil, err
291290
}
292-
err = ioutil.WriteFile(macFilePath, walletKitMacBytes, 0644)
291+
err = os.WriteFile(macFilePath, walletKitMacBytes, 0644)
293292
if err != nil {
294293
_ = os.Remove(macFilePath)
295294
return nil, nil, err

0 commit comments

Comments
 (0)