Skip to content

Commit

Permalink
interfaces: do not sync on output writers
Browse files Browse the repository at this point in the history
Fixes:

  sync /dev/stdout: inappropriate ioctl for device

When the writer is os.Stdout. (*os.File).Close() does flush the file to
disk either way, so calling Sync() directly is redundant.
  • Loading branch information
rjeczalik committed May 1, 2019
1 parent 4dd7b3e commit 073b0dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/interfacer/main.go
Expand Up @@ -92,7 +92,7 @@ func main() {
die(err)
}
}
err = nonil(tmpl.Execute(f, v), f.Sync(), f.Close())
err = nonil(tmpl.Execute(f, v), f.Close())
if err != nil {
die(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/structer/main.go
Expand Up @@ -171,7 +171,7 @@ func run() (err error) {
}
}

return nonil(tmpl.Execute(w, &v), appendTemplate(*typ, &v, w), w.Sync(), w.Close())
return nonil(tmpl.Execute(w, &v), appendTemplate(*typ, &v, w), w.Close())
}

var tmplFuncs = template.FuncMap{
Expand Down

0 comments on commit 073b0dc

Please sign in to comment.