Skip to content

Commit

Permalink
Fix autofix mode for directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krivak committed May 16, 2020
1 parent 1d1cebb commit d40d72a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/godot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func main() {
settings.CheckAll = true
}

var paths []string
var files []*ast.File
fset := token.NewFileSet()

Expand All @@ -69,20 +70,21 @@ func main() {
fatalf("Failed to parse file '%s': %v", path, err)
}
files = append(files, file)
paths = append(paths, f)
}
}

for i := range files {
switch {
case args.fix:
fixed, err := godot.Fix(args.files[i], files[i], fset, settings)
fixed, err := godot.Fix(paths[i], files[i], fset, settings)
if err != nil {
fatalf("Failed to autofix file '%s': %v", args.files[i], err)
fatalf("Failed to autofix file '%s': %v", paths[i], err)
}
fmt.Print(string(fixed))
case args.write:
if err := godot.Replace(args.files[i], files[i], fset, settings); err != nil {
fatalf("Failed to rewrite file '%s': %v", args.files[i], err)
if err := godot.Replace(paths[i], files[i], fset, settings); err != nil {
fatalf("Failed to rewrite file '%s': %v", paths[i], err)
}
default:
issues := godot.Run(files[i], fset, settings)
Expand Down

0 comments on commit d40d72a

Please sign in to comment.