[dev.link] cmd/compile, cmd/asm: use bio.Writer for object file writing

It is convenient to have a seekable writer. A later CL will make
use of Seek.

Change-Id: Iba0107ce2975d9a451d97f16aa91a318dd4c90e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/196028
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2019-09-11 16:11:31 -04:00
parent dc8453964a
commit cd75cf4bc0
3 changed files with 7 additions and 7 deletions

View file

@ -46,12 +46,11 @@ func main() {
architecture.Init(ctxt)
// Create object file, write header.
out, err := os.Create(*flags.OutputFile)
buf, err := bio.Create(*flags.OutputFile)
if err != nil {
log.Fatal(err)
}
defer bio.MustClose(out)
buf := bufio.NewWriter(bio.MustWriter(out))
defer buf.Close()
if !*flags.SymABIs {
fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
@ -91,9 +90,8 @@ func main() {
} else {
log.Print("assembly failed")
}
out.Close()
buf.Close()
os.Remove(*flags.OutputFile)
os.Exit(1)
}
buf.Flush()
}