diff --git a/fs.go b/fs.go index f11903e..d1d20c9 100644 --- a/fs.go +++ b/fs.go @@ -9,7 +9,6 @@ import ( "go/parser" "go/token" "io/fs" - "io/ioutil" "os" "path/filepath" "regexp" @@ -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) } diff --git a/main.go b/main.go index 23877ac..6c2932e 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ package main import ( "flag" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -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) } } diff --git a/pkg/gimps/gimps.go b/pkg/gimps/gimps.go index 069d924..a84043c 100644 --- a/pkg/gimps/gimps.go +++ b/pkg/gimps/gimps.go @@ -11,7 +11,7 @@ import ( "go/parser" "go/printer" "go/token" - "io/ioutil" + "os" "sort" "strings" ) @@ -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 } diff --git a/pkg/gimps/gimps_test.go b/pkg/gimps/gimps_test.go index 1f65de4..6c10944 100644 --- a/pkg/gimps/gimps_test.go +++ b/pkg/gimps/gimps_test.go @@ -4,7 +4,6 @@ package gimps import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -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)) })