Skip to content

Commit

Permalink
do not use ioutil anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
xrstf committed Oct 25, 2023
1 parent 9dd5db7 commit f7c4198
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"go/parser"
"go/token"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -100,7 +99,7 @@ var (
)

func isGeneratedFile(filename string) (bool, error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return false, fmt.Errorf("failed to read file: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -132,7 +131,7 @@ func main() {
}

if !dryRun {
if err := ioutil.WriteFile(filename, formattedOutput, 0644); err != nil {
if err := os.WriteFile(filename, formattedOutput, 0644); err != nil {
log.Fatalf("Failed to write fixed result to file %q: %v", filename, err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/gimps/gimps.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"go/parser"
"go/printer"
"go/token"
"io/ioutil"
"os"
"sort"
"strings"
)
Expand Down Expand Up @@ -51,7 +51,7 @@ func (p *importPosition) IsInRange(comment *ast.CommentGroup) bool {
func Execute(config *Config, filePath string, aliaser *Aliaser) ([]byte, bool, error) {
setDefaults(config)

originalContent, err := ioutil.ReadFile(filePath)
originalContent, err := os.ReadFile(filePath)
if err != nil {
return nil, false, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/gimps/gimps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package gimps

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -56,7 +55,7 @@ func TestExecute(t *testing.T) {
}

expectedFile := filepath.Join(testcase, "main.go.expected")
expected, err := ioutil.ReadFile(expectedFile)
expected, err := os.ReadFile(expectedFile)
require.Nil(t, err)
assert.Equal(t, string(expected), string(output))
})
Expand Down

0 comments on commit f7c4198

Please sign in to comment.