@@ -22,7 +22,6 @@ import (
22
22
"crypto/rand"
23
23
"errors"
24
24
"fmt"
25
- "io/ioutil"
26
25
"math/big"
27
26
"os"
28
27
"regexp"
@@ -67,7 +66,7 @@ func GetNonEmptyLines(output string) []string {
67
66
func InsertCode (filename , target , code string ) error {
68
67
// false positive
69
68
// nolint:gosec
70
- contents , err := ioutil .ReadFile (filename )
69
+ contents , err := os .ReadFile (filename )
71
70
if err != nil {
72
71
return err
73
72
}
@@ -78,15 +77,15 @@ func InsertCode(filename, target, code string) error {
78
77
out := string (contents [:idx + len (target )]) + code + string (contents [idx + len (target ):])
79
78
// false positive
80
79
// nolint:gosec
81
- return ioutil .WriteFile (filename , []byte (out ), 0644 )
80
+ return os .WriteFile (filename , []byte (out ), 0644 )
82
81
}
83
82
84
83
// UncommentCode searches for target in the file and remove the comment prefix
85
84
// of the target content. The target content may span multiple lines.
86
85
func UncommentCode (filename , target , prefix string ) error {
87
86
// false positive
88
87
// nolint:gosec
89
- content , err := ioutil .ReadFile (filename )
88
+ content , err := os .ReadFile (filename )
90
89
if err != nil {
91
90
return err
92
91
}
@@ -127,14 +126,14 @@ func UncommentCode(filename, target, prefix string) error {
127
126
}
128
127
// false positive
129
128
// nolint:gosec
130
- return ioutil .WriteFile (filename , out .Bytes (), 0644 )
129
+ return os .WriteFile (filename , out .Bytes (), 0644 )
131
130
}
132
131
133
132
// ImplementWebhooks will mock an webhook data
134
133
func ImplementWebhooks (filename string ) error {
135
134
// false positive
136
135
// nolint:gosec
137
- bs , err := ioutil .ReadFile (filename )
136
+ bs , err := os .ReadFile (filename )
138
137
if err != nil {
139
138
return err
140
139
}
@@ -181,7 +180,7 @@ func ImplementWebhooks(filename string) error {
181
180
}
182
181
// false positive
183
182
// nolint:gosec
184
- return ioutil .WriteFile (filename , []byte (str ), 0644 )
183
+ return os .WriteFile (filename , []byte (str ), 0644 )
185
184
}
186
185
187
186
// EnsureExistAndReplace check if the content exists and then do the replace
@@ -200,15 +199,15 @@ func ReplaceInFile(path, old, new string) error {
200
199
}
201
200
// false positive
202
201
// nolint:gosec
203
- b , err := ioutil .ReadFile (path )
202
+ b , err := os .ReadFile (path )
204
203
if err != nil {
205
204
return err
206
205
}
207
206
if ! strings .Contains (string (b ), old ) {
208
207
return errors .New ("unable to find the content to be replaced" )
209
208
}
210
209
s := strings .Replace (string (b ), old , new , - 1 )
211
- err = ioutil .WriteFile (path , []byte (s ), info .Mode ())
210
+ err = os .WriteFile (path , []byte (s ), info .Mode ())
212
211
if err != nil {
213
212
return err
214
213
}
@@ -228,15 +227,15 @@ func ReplaceRegexInFile(path, match, replace string) error {
228
227
}
229
228
// false positive
230
229
// nolint:gosec
231
- b , err := ioutil .ReadFile (path )
230
+ b , err := os .ReadFile (path )
232
231
if err != nil {
233
232
return err
234
233
}
235
234
s := matcher .ReplaceAllString (string (b ), replace )
236
235
if s == string (b ) {
237
236
return errors .New ("unable to find the content to be replaced" )
238
237
}
239
- err = ioutil .WriteFile (path , []byte (s ), info .Mode ())
238
+ err = os .WriteFile (path , []byte (s ), info .Mode ())
240
239
if err != nil {
241
240
return err
242
241
}
@@ -246,7 +245,7 @@ func ReplaceRegexInFile(path, match, replace string) error {
246
245
// HasFileContentWith check if given `text` can be found in file
247
246
func HasFileContentWith (path , text string ) (bool , error ) {
248
247
// nolint:gosec
249
- contents , err := ioutil .ReadFile (path )
248
+ contents , err := os .ReadFile (path )
250
249
if err != nil {
251
250
return false , err
252
251
}
0 commit comments