15
15
package addlicense
16
16
17
17
import (
18
- "io/ioutil"
19
18
"os"
20
19
"os/exec"
21
20
"path/filepath"
@@ -33,7 +32,7 @@ func run(t *testing.T, name string, args ...string) {
33
32
}
34
33
35
34
func tempDir (t * testing.T ) string {
36
- dir , err := ioutil . TempDir ("" , "addlicense" )
35
+ dir , err := os . MkdirTemp ("" , "addlicense" )
37
36
if err != nil {
38
37
t .Fatal (err )
39
38
}
@@ -209,12 +208,12 @@ func TestMPL(t *testing.T) {
209
208
}
210
209
211
210
func createTempFile (contents string , pattern string ) (* os.File , error ) {
212
- f , err := ioutil . TempFile ("" , pattern )
211
+ f , err := os . CreateTemp ("" , pattern )
213
212
if err != nil {
214
213
return nil , err
215
214
}
216
215
217
- if err := ioutil .WriteFile (f .Name (), []byte (contents ), 0644 ); err != nil {
216
+ if err := os .WriteFile (f .Name (), []byte (contents ), 0644 ); err != nil {
218
217
return nil , err
219
218
}
220
219
@@ -275,7 +274,7 @@ func TestAddLicense(t *testing.T) {
275
274
if updated != tt .wantUpdated {
276
275
t .Errorf ("addLicense with contents %q returned updated: %t, want %t" , tt .contents , updated , tt .wantUpdated )
277
276
}
278
- gotContents , err := ioutil .ReadFile (f .Name ())
277
+ gotContents , err := os .ReadFile (f .Name ())
279
278
if err != nil {
280
279
t .Error (err )
281
280
}
0 commit comments