Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
crashdump committed Aug 1, 2023
1 parent 9bc3aae commit 361f1b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions cmd/edmgen/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func writeFileTxt(filename string, lines []string) error {
if err != nil {
return fmt.Errorf("failed to create file: %s", err)
}
defer f.Close()

for _, line := range lines {
_, err := f.WriteString(line + "\n")
Expand All @@ -171,15 +170,14 @@ func writeFileTxt(filename string, lines []string) error {
}
}

return nil
return f.Close()
}

func writeFileCsv(filename string, lines []string) error {
f, err := os.Create(filename)
if err != nil {
return fmt.Errorf("failed to create file: %s", err)
}
defer f.Close()

w := csv.NewWriter(f)
defer w.Flush()
Expand All @@ -190,5 +188,5 @@ func writeFileCsv(filename string, lines []string) error {
}
}

return nil
return f.Close()
}
10 changes: 3 additions & 7 deletions cmd/edmgen/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ func (l logging) print(str string) {
}

func (l logging) printHeader(str string) {
l.logger.Print(fmt.Sprintf("> %s", str))
l.logger.Printf("> %s", str)
}

func (l logging) printResult(str string) {
l.logger.Print(fmt.Sprintf(" %s", str))
l.logger.Printf(" %s", str)
}

func (l logging) printfResult(format string, args interface{}) {
l.printResult(fmt.Sprintf(format, args))
}

func (l logging) printWarn(str string) {
l.logger.Print(fmt.Sprintf("[!] %s", str))
}

func (l logging) printFatal(str string) {
func (logging) printFatal(str string) {
panic(str)
}

0 comments on commit 361f1b3

Please sign in to comment.