diff --git a/ast/character_literal_test.go b/ast/character_literal_test.go index 2528ba9d1..d9a1ee36e 100644 --- a/ast/character_literal_test.go +++ b/ast/character_literal_test.go @@ -3,7 +3,6 @@ package ast import ( "fmt" "github.com/elliotchance/c2go/cc" - "io/ioutil" "os" "path" "testing" @@ -347,14 +346,14 @@ func TestCharacterLiteralRepairFromSource(t *testing.T) { func prepareRepairFromSourceTest(t *testing.T, fileContent string, test func(filePath string)) { cc.ResetCache() - dir, err := ioutil.TempDir("", "c2go") + dir, err := os.MkdirTemp("", "c2go") if err != nil { t.Fatal(fmt.Errorf("Cannot create temp folder: %v", err)) } defer os.RemoveAll(dir) // clean up ppFilePath := path.Join(dir, "pp.c") - err = ioutil.WriteFile(ppFilePath, []byte(fileContent), 0644) + err = os.WriteFile(ppFilePath, []byte(fileContent), 0644) if err != nil { t.Fatal(fmt.Errorf("writing to %s failed: %v", ppFilePath, err)) } diff --git a/cc/preprocessor.go b/cc/preprocessor.go index 63df0a12a..3b72cda54 100644 --- a/cc/preprocessor.go +++ b/cc/preprocessor.go @@ -2,7 +2,7 @@ package cc import ( "fmt" - "io/ioutil" + "os" "strings" "github.com/elliotchance/c2go/util" @@ -26,7 +26,7 @@ func GetLineFromPreprocessedFile(inputFilePath, filePath string, lineNumber int) if fileCache == nil { fileCache = map[string]map[int]string{} - inputFile, err := ioutil.ReadFile(inputFilePath) + inputFile, err := os.ReadFile(inputFilePath) if err != nil { return "", err } diff --git a/main.go b/main.go index afb31e1dd..a4824c496 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "os/exec" "path" @@ -198,14 +197,14 @@ func Start(args ProgramArgs) (err error) { if args.verbose { fmt.Println("Writing preprocessor ...") } - dir, err := ioutil.TempDir("", "c2go") + dir, err := os.MkdirTemp("", "c2go") if err != nil { return fmt.Errorf("Cannot create temp folder: %v", err) } defer os.RemoveAll(dir) // clean up ppFilePath := path.Join(dir, "pp.c") - err = ioutil.WriteFile(ppFilePath, pp, 0644) + err = os.WriteFile(ppFilePath, pp, 0644) if err != nil { return fmt.Errorf("writing to %s failed: %v", ppFilePath, err) } @@ -304,7 +303,7 @@ func Start(args ProgramArgs) (err error) { if args.verbose { fmt.Println("Writing the output Go code...") } - err = ioutil.WriteFile(outputFilePath, []byte(p.String()), 0644) + err = os.WriteFile(outputFilePath, []byte(p.String()), 0644) if err != nil { return fmt.Errorf("writing Go output file failed: %v", err) } diff --git a/noarch/stdio.go b/noarch/stdio.go index 06f348f87..cc318de47 100644 --- a/noarch/stdio.go +++ b/noarch/stdio.go @@ -3,7 +3,6 @@ package noarch import ( "fmt" "io" - "io/ioutil" "os" "reflect" "strings" @@ -231,7 +230,7 @@ func Fputs(str *byte, stream *File) int32 { // abnormally, whether the file is deleted depends on the specific system and // library implementation. func Tmpfile() *File { - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") if err != nil { return nil } @@ -396,7 +395,7 @@ func Tmpnam(str *byte) *byte { // great distinct Go temp file generation (that also checks for existing // files), but unfortunately creates the file in the process; even if you // don't intend to use it. - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") if err != nil { return nil } diff --git a/preprocessor/preprocessor.go b/preprocessor/preprocessor.go index 2752fb556..f78a53090 100644 --- a/preprocessor/preprocessor.go +++ b/preprocessor/preprocessor.go @@ -4,7 +4,6 @@ import ( "bufio" "bytes" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -212,7 +211,7 @@ func analyzeFiles(inputFiles, clangFlags []string, verbose bool) (items []entity // clang -E Run the preprocessor stage. func getPreprocessSources(inputFiles, clangFlags []string, verbose bool) (out bytes.Buffer, err error) { // get temp dir - dir, err := ioutil.TempDir("", "c2go-union") + dir, err := os.MkdirTemp("", "c2go-union") if err != nil { return } @@ -233,7 +232,7 @@ func getPreprocessSources(inputFiles, clangFlags []string, verbose bool) (out by } // write a union file - err = ioutil.WriteFile(unionFileName, []byte(unionBody), 0644) + err = os.WriteFile(unionFileName, []byte(unionBody), 0644) if err != nil { return }