File tree Expand file tree Collapse file tree 6 files changed +10
-14
lines changed Expand file tree Collapse file tree 6 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package gosec_test
2
2
3
3
import (
4
4
"errors"
5
- "io/ioutil"
6
5
"log"
7
6
"os"
8
7
"strings"
@@ -30,7 +29,7 @@ var _ = Describe("Analyzer", func() {
30
29
Context ("when processing a package" , func () {
31
30
It ("should not report an error if the package contains no Go files" , func () {
32
31
analyzer .LoadRules (rules .Generate (false ).RulesInfo ())
33
- dir , err := ioutil . TempDir ("" , "empty" )
32
+ dir , err := os . MkdirTemp ("" , "empty" )
34
33
defer os .RemoveAll (dir )
35
34
Expect (err ).ShouldNot (HaveOccurred ())
36
35
err = analyzer .Process (buildTags , dir )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ package main
17
17
import (
18
18
"flag"
19
19
"fmt"
20
- "io/ioutil "
20
+ "io"
21
21
"log"
22
22
"os"
23
23
"runtime"
@@ -354,7 +354,7 @@ func main() {
354
354
}
355
355
356
356
if * flagQuiet {
357
- logger = log .New (ioutil .Discard , "" , 0 )
357
+ logger = log .New (io .Discard , "" , 0 )
358
358
} else {
359
359
logger = log .New (logWriter , "[gosec] " , log .LstdFlags )
360
360
}
Original file line number Diff line number Diff line change 7
7
"flag"
8
8
"fmt"
9
9
"go/format"
10
- "io/ioutil"
11
10
"log"
12
11
"net/http"
12
+ "os"
13
13
"path/filepath"
14
14
15
15
"github.com/mozilla/tls-observatory/constants"
@@ -187,7 +187,7 @@ func main() {
187
187
}
188
188
189
189
outputPath := filepath .Join (dir , * outputFile )
190
- if err := ioutil .WriteFile (outputPath , src , 0o644 ); err != nil {
190
+ if err := os .WriteFile (outputPath , src , 0o644 ); err != nil {
191
191
log .Fatalf ("Writing output: %s" , err )
192
192
} //#nosec G306
193
193
}
Original file line number Diff line number Diff line change 5
5
"encoding/json"
6
6
"fmt"
7
7
"io"
8
- "io/ioutil"
9
8
)
10
9
11
10
const (
@@ -64,7 +63,7 @@ func (c Config) convertGlobals() {
64
63
// should be used with io.Reader to load configuration from
65
64
// file or from string etc.
66
65
func (c Config ) ReadFrom (r io.Reader ) (int64 , error ) {
67
- data , err := ioutil .ReadAll (r )
66
+ data , err := io .ReadAll (r )
68
67
if err != nil {
69
68
return int64 (len (data )), err
70
69
}
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package gosec_test
2
2
3
3
import (
4
4
"go/ast"
5
- "io/ioutil"
6
5
"os"
7
6
"path/filepath"
8
7
"regexp"
@@ -18,9 +17,9 @@ var _ = Describe("Helpers", func() {
18
17
var dir string
19
18
JustBeforeEach (func () {
20
19
var err error
21
- dir , err = ioutil . TempDir ("" , "gosec" )
20
+ dir , err = os . MkdirTemp ("" , "gosec" )
22
21
Expect (err ).ShouldNot (HaveOccurred ())
23
- _ , err = ioutil . TempFile (dir , "test*.go" )
22
+ _ , err = os . MkdirTemp (dir , "test*.go" )
24
23
Expect (err ).ShouldNot (HaveOccurred ())
25
24
})
26
25
AfterEach (func () {
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package testutils
3
3
import (
4
4
"fmt"
5
5
"go/build"
6
- "io/ioutil"
7
6
"log"
8
7
"os"
9
8
"path"
@@ -30,7 +29,7 @@ type TestPackage struct {
30
29
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
31
30
// auxiliary files
32
31
func NewTestPackage () * TestPackage {
33
- workingDir , err := ioutil . TempDir ("" , "gosecs_test" )
32
+ workingDir , err := os . MkdirTemp ("" , "gosecs_test" )
34
33
if err != nil {
35
34
return nil
36
35
}
@@ -53,7 +52,7 @@ func (p *TestPackage) write() error {
53
52
return nil
54
53
}
55
54
for filename , content := range p .Files {
56
- if e := ioutil .WriteFile (filename , []byte (content ), 0o644 ); e != nil {
55
+ if e := os .WriteFile (filename , []byte (content ), 0o644 ); e != nil {
57
56
return e
58
57
} //#nosec G306
59
58
}
You can’t perform that action at this time.
0 commit comments