mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj: remove use of package bio
Also add MustClose and MustWriter to cmd/internal/bio, and use them in cmd/asm. Change-Id: I07f5df3b66c17bc5b2e6ec9c4357d9b653e354e0 Reviewed-on: https://go-review.googlesource.com/21938 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
b623b71509
commit
045411e6f2
5 changed files with 57 additions and 12 deletions
|
|
@ -44,12 +44,15 @@ func main() {
|
|||
defer ctxt.Bso.Flush()
|
||||
|
||||
// Create object file, write header.
|
||||
output, err := bio.Create(*flags.OutputFile)
|
||||
out, err := os.Create(*flags.OutputFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Fprintf(output, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
|
||||
fmt.Fprintf(output, "!\n")
|
||||
defer bio.MustClose(out)
|
||||
buf := bufio.NewWriter(bio.MustWriter(out))
|
||||
|
||||
fmt.Fprintf(buf, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
|
||||
fmt.Fprintf(buf, "!\n")
|
||||
|
||||
lexer := lex.NewLexer(flag.Arg(0), ctxt)
|
||||
parser := asm.NewParser(ctxt, architecture, lexer)
|
||||
|
|
@ -63,12 +66,12 @@ func main() {
|
|||
pList.Firstpc, ok = parser.Parse()
|
||||
if ok {
|
||||
// reports errors to parser.Errorf
|
||||
obj.Writeobjdirect(ctxt, output)
|
||||
obj.Writeobjdirect(ctxt, buf)
|
||||
}
|
||||
if !ok || diag {
|
||||
log.Printf("assembly of %s failed", flag.Arg(0))
|
||||
os.Remove(*flags.OutputFile)
|
||||
os.Exit(1)
|
||||
}
|
||||
output.Flush()
|
||||
buf.Flush()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue