Skip to content

Commit

Permalink
cosme
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoshiki41 committed May 3, 2024
1 parent 42e3696 commit c93d0bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"flag"
"format/gofmt"

Check failure on line 6 in main.go

View workflow job for this annotation

GitHub Actions / build

package format/gofmt is not in std (/home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.2.linux-amd64/src/format/gofmt)
"go/ast"
"go/parser"
"go/token"
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
}
defer output.Close()

// TODO: Restore original file if we encounter an error
writer := bufio.NewWriter(output)
for _, line := range lines {
if _, err := writer.WriteString(line + "\n"); err != nil {
Expand All @@ -72,4 +74,9 @@ func main() {
if err := writer.Flush(); err != nil {
log.Fatalf("Failed to flush writer: %v", err)
}

// run gofmt on the file
if err := gofmt.Format(fileName); err != nil {
log.Fatalf("Failed to run gofmt: %v", err)
}
}

0 comments on commit c93d0bc

Please sign in to comment.