@@ -88,7 +88,6 @@ import (
88
88
"fmt"
89
89
"go/build"
90
90
"io"
91
- "io/ioutil"
92
91
"log"
93
92
"os"
94
93
"os/exec"
@@ -166,7 +165,7 @@ func runRelease(ctx context.Context, w io.Writer, dir string, args []string) (su
166
165
// test without printing to stderr.
167
166
fs := flag .NewFlagSet ("gorelease" , flag .ContinueOnError )
168
167
fs .Usage = func () {}
169
- fs .SetOutput (ioutil .Discard )
168
+ fs .SetOutput (io .Discard )
170
169
var baseOpt , releaseVersion string
171
170
fs .StringVar (& baseOpt , "base" , "" , "previous version to compare against" )
172
171
fs .StringVar (& releaseVersion , "version" , "" , "proposed version to be released" )
@@ -309,7 +308,7 @@ func loadLocalModule(ctx context.Context, modRoot, repoRoot, version string) (m
309
308
m .diagnostics = append (m .diagnostics , fmt .Sprintf ("Version %s is lower than most pseudo-versions. Consider releasing v0.1.0-0 instead." , version ))
310
309
}
311
310
312
- m .goModData , err = ioutil .ReadFile (m .goModPath )
311
+ m .goModData , err = os .ReadFile (m .goModPath )
313
312
if err != nil {
314
313
return moduleInfo {}, err
315
314
}
@@ -371,7 +370,7 @@ func loadLocalModule(ctx context.Context, modRoot, repoRoot, version string) (m
371
370
// Modules with major version suffixes can be defined in two places
372
371
// (e.g., sub/go.mod and sub/v2/go.mod). They must not be defined in both.
373
372
if altGoModPath != "" {
374
- if data , err := ioutil .ReadFile (altGoModPath ); err == nil {
373
+ if data , err := os .ReadFile (altGoModPath ); err == nil {
375
374
if altModPath := modfile .ModulePath (data ); m .modPath == altModPath {
376
375
goModRel , _ := filepath .Rel (repoRoot , m .goModPath )
377
376
altGoModRel , _ := filepath .Rel (repoRoot , altGoModPath )
@@ -511,7 +510,7 @@ func loadDownloadedModule(ctx context.Context, modPath, version, max string) (m
511
510
if m .modRoot , m .goModPath , err = downloadModule (ctx , v ); err != nil {
512
511
return moduleInfo {}, err
513
512
}
514
- if m .goModData , err = ioutil .ReadFile (m .goModPath ); err != nil {
513
+ if m .goModData , err = os .ReadFile (m .goModPath ); err != nil {
515
514
return moduleInfo {}, err
516
515
}
517
516
if m .goModFile , err = modfile .ParseLax (m .goModPath , m .goModData , nil ); err != nil {
@@ -774,7 +773,7 @@ func queryVersion(ctx context.Context, modPath, query string) (resolved string,
774
773
return "" , errors .New ("query is based on requirements in main go.mod file" )
775
774
}
776
775
777
- tmpDir , err := ioutil . TempDir ("" , "" )
776
+ tmpDir , err := os . MkdirTemp ("" , "" )
778
777
if err != nil {
779
778
return "" , err
780
779
}
@@ -805,7 +804,7 @@ func loadVersions(ctx context.Context, modPath string) (versions []string, err e
805
804
}
806
805
}()
807
806
808
- tmpDir , err := ioutil . TempDir ("" , "" )
807
+ tmpDir , err := os . MkdirTemp ("" , "" )
809
808
if err != nil {
810
809
return nil , err
811
810
}
@@ -882,7 +881,7 @@ func copyModuleToTempDir(repoRoot, modPath, modRoot string) (dir string, err err
882
881
}
883
882
m := module.Version {Path : modPath , Version : version }
884
883
885
- zipFile , err := ioutil . TempFile ("" , "gorelease-*.zip" )
884
+ zipFile , err := os . CreateTemp ("" , "gorelease-*.zip" )
886
885
if err != nil {
887
886
return "" , err
888
887
}
@@ -891,7 +890,7 @@ func copyModuleToTempDir(repoRoot, modPath, modRoot string) (dir string, err err
891
890
os .Remove (zipFile .Name ())
892
891
}()
893
892
894
- dir , err = ioutil . TempDir ("" , "gorelease" )
893
+ dir , err = os . MkdirTemp ("" , "gorelease" )
895
894
if err != nil {
896
895
return "" , err
897
896
}
@@ -980,7 +979,7 @@ func downloadModule(ctx context.Context, m module.Version) (modRoot, goModPath s
980
979
// TODO(golang.org/issue/36812): 'go mod download' reads go.mod even though
981
980
// we don't need information about the main module or the build list.
982
981
// If it didn't read go.mod in this case, we wouldn't need a temp directory.
983
- tmpDir , err := ioutil . TempDir ("" , "gorelease-download" )
982
+ tmpDir , err := os . MkdirTemp ("" , "gorelease-download" )
984
983
if err != nil {
985
984
return "" , "" , err
986
985
}
@@ -1073,7 +1072,7 @@ func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot
1073
1072
}
1074
1073
}
1075
1074
1076
- dir , err = ioutil . TempDir ("" , "gorelease-load" )
1075
+ dir , err = os . MkdirTemp ("" , "gorelease-load" )
1077
1076
if err != nil {
1078
1077
return "" , nil , nil , nil , nil , err
1079
1078
}
@@ -1096,15 +1095,15 @@ func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot
1096
1095
if err != nil {
1097
1096
return "" , nil , nil , nil , nil , err
1098
1097
}
1099
- if err := ioutil .WriteFile (filepath .Join (dir , "go.mod" ), goModData , 0666 ); err != nil {
1098
+ if err := os .WriteFile (filepath .Join (dir , "go.mod" ), goModData , 0666 ); err != nil {
1100
1099
return "" , nil , nil , nil , nil , err
1101
1100
}
1102
1101
1103
- goSumData , err = ioutil .ReadFile (filepath .Join (modRoot , "go.sum" ))
1102
+ goSumData , err = os .ReadFile (filepath .Join (modRoot , "go.sum" ))
1104
1103
if err != nil && ! os .IsNotExist (err ) {
1105
1104
return "" , nil , nil , nil , nil , err
1106
1105
}
1107
- if err := ioutil .WriteFile (filepath .Join (dir , "go.sum" ), goSumData , 0666 ); err != nil {
1106
+ if err := os .WriteFile (filepath .Join (dir , "go.sum" ), goSumData , 0666 ); err != nil {
1108
1107
return "" , nil , nil , nil , nil , err
1109
1108
}
1110
1109
@@ -1119,7 +1118,7 @@ func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot
1119
1118
for _ , imp := range imps {
1120
1119
fmt .Fprintf (fakeImports , "import _ %q\n " , imp )
1121
1120
}
1122
- if err := ioutil .WriteFile (filepath .Join (dir , "tmp.go" ), []byte (fakeImports .String ()), 0666 ); err != nil {
1121
+ if err := os .WriteFile (filepath .Join (dir , "tmp.go" ), []byte (fakeImports .String ()), 0666 ); err != nil {
1123
1122
return "" , nil , nil , nil , nil , err
1124
1123
}
1125
1124
@@ -1148,7 +1147,7 @@ func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot
1148
1147
if err != nil {
1149
1148
return "" , nil , nil , nil , nil , err
1150
1149
}
1151
- newGoModData , err := ioutil .ReadFile (goModPath )
1150
+ newGoModData , err := os .ReadFile (goModPath )
1152
1151
if err != nil {
1153
1152
return "" , nil , nil , nil , nil , err
1154
1153
}
@@ -1187,7 +1186,7 @@ func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot
1187
1186
if ! cached {
1188
1187
// Check if 'go get' added new hashes to go.sum.
1189
1188
goSumPath := filepath .Join (dir , "go.sum" )
1190
- newGoSumData , err := ioutil .ReadFile (goSumPath )
1189
+ newGoSumData , err := os .ReadFile (goSumPath )
1191
1190
if err != nil {
1192
1191
if ! os .IsNotExist (err ) {
1193
1192
return "" , nil , nil , nil , nil , err
0 commit comments