@@ -11,7 +11,6 @@ import (
11
11
"encoding/binary"
12
12
"flag"
13
13
"fmt"
14
- "io/ioutil"
15
14
"log"
16
15
"os"
17
16
"os/exec"
@@ -125,7 +124,7 @@ func testMain(m *testing.M) int {
125
124
// Copy testdata into GOPATH/src/testcshared, along with a go.mod file
126
125
// declaring the same path.
127
126
128
- GOPATH , err := ioutil . TempDir ("" , "cshared_test" )
127
+ GOPATH , err := os . MkdirTemp ("" , "cshared_test" )
129
128
if err != nil {
130
129
log .Panic (err )
131
130
}
@@ -140,7 +139,7 @@ func testMain(m *testing.M) int {
140
139
log .Panic (err )
141
140
}
142
141
os .Setenv ("PWD" , modRoot )
143
- if err := ioutil .WriteFile ("go.mod" , []byte ("module testcshared\n " ), 0666 ); err != nil {
142
+ if err := os .WriteFile ("go.mod" , []byte ("module testcshared\n " ), 0666 ); err != nil {
144
143
log .Panic (err )
145
144
}
146
145
@@ -260,7 +259,7 @@ func createHeaders() error {
260
259
// The 'cgo' command generates a number of additional artifacts,
261
260
// but we're only interested in the header.
262
261
// Shunt the rest of the outputs to a temporary directory.
263
- objDir , err := ioutil . TempDir ("" , "testcshared_obj" )
262
+ objDir , err := os . MkdirTemp ("" , "testcshared_obj" )
264
263
if err != nil {
265
264
return err
266
265
}
@@ -381,7 +380,7 @@ func main() {
381
380
382
381
srcfile := filepath .Join (tmpdir , "test.go" )
383
382
objfile := filepath .Join (tmpdir , "test.dll" )
384
- if err := ioutil .WriteFile (srcfile , []byte (prog ), 0666 ); err != nil {
383
+ if err := os .WriteFile (srcfile , []byte (prog ), 0666 ); err != nil {
385
384
t .Fatal (err )
386
385
}
387
386
argv := []string {"build" , "-buildmode=c-shared" }
@@ -643,7 +642,7 @@ func TestPIE(t *testing.T) {
643
642
644
643
// Test that installing a second time recreates the header file.
645
644
func TestCachedInstall (t * testing.T ) {
646
- tmpdir , err := ioutil . TempDir ("" , "cshared" )
645
+ tmpdir , err := os . MkdirTemp ("" , "cshared" )
647
646
if err != nil {
648
647
t .Fatal (err )
649
648
}
@@ -719,14 +718,14 @@ func TestCachedInstall(t *testing.T) {
719
718
// copyFile copies src to dst.
720
719
func copyFile (t * testing.T , dst , src string ) {
721
720
t .Helper ()
722
- data , err := ioutil .ReadFile (src )
721
+ data , err := os .ReadFile (src )
723
722
if err != nil {
724
723
t .Fatal (err )
725
724
}
726
725
if err := os .MkdirAll (filepath .Dir (dst ), 0777 ); err != nil {
727
726
t .Fatal (err )
728
727
}
729
- if err := ioutil .WriteFile (dst , data , 0666 ); err != nil {
728
+ if err := os .WriteFile (dst , data , 0666 ); err != nil {
730
729
t .Fatal (err )
731
730
}
732
731
}
@@ -743,7 +742,7 @@ func TestGo2C2Go(t *testing.T) {
743
742
744
743
t .Parallel ()
745
744
746
- tmpdir , err := ioutil . TempDir ("" , "cshared-TestGo2C2Go" )
745
+ tmpdir , err := os . MkdirTemp ("" , "cshared-TestGo2C2Go" )
747
746
if err != nil {
748
747
t .Fatal (err )
749
748
}
0 commit comments