1
0
mirror of https://github.com/golang/go synced 2024-11-18 23:54:41 -07:00

cmd: remove bio.BufReader and bio.BufWriter

bio.BufReader was never used.

bio.BufWriter was used to wrap an existing io.Writer, but the
bio.Writer returned would not be seekable, so replace all occurences
with bufio.Reader instead.

Change-Id: I9c6779e35c63178aa4e104c17bb5bb8b52de0359
Reviewed-on: https://go-review.googlesource.com/21722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Dave Cheney 2016-04-08 19:30:41 +10:00
parent 6fee4aa5c7
commit ca397bb68e
11 changed files with 28 additions and 40 deletions

View File

@ -5,6 +5,7 @@
package asm
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
@ -17,7 +18,6 @@ import (
"testing"
"cmd/asm/internal/lex"
"cmd/internal/bio"
"cmd/internal/obj"
)
@ -34,7 +34,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
pList := obj.Linknewplist(ctxt)
var ok bool
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
ctxt.Bso = bio.BufWriter(os.Stdout)
ctxt.Bso = bufio.NewWriter(os.Stdout)
defer ctxt.Bso.Flush()
failed := false
ctxt.DiagFunc = func(format string, args ...interface{}) {
@ -272,7 +272,7 @@ func testErrors(t *testing.T, goarch, file string) {
pList := obj.Linknewplist(ctxt)
var ok bool
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
ctxt.Bso = bio.BufWriter(os.Stdout)
ctxt.Bso = bufio.NewWriter(os.Stdout)
defer ctxt.Bso.Flush()
failed := false
var errBuf bytes.Buffer

View File

@ -5,6 +5,7 @@
package main
import (
"bufio"
"flag"
"fmt"
"log"
@ -32,11 +33,6 @@ func main() {
flags.Parse()
// Create object file, write header.
fd, err := os.Create(*flags.OutputFile)
if err != nil {
log.Fatal(err)
}
ctxt := obj.Linknew(architecture.LinkArch)
if *flags.PrintOut {
ctxt.Debugasm = 1
@ -46,9 +42,14 @@ func main() {
if *flags.Shared || *flags.Dynlink {
ctxt.Flag_shared = 1
}
ctxt.Bso = bio.BufWriter(os.Stdout)
ctxt.Bso = bufio.NewWriter(os.Stdout)
defer ctxt.Bso.Flush()
output := bio.BufWriter(fd)
// Create object file, write header.
output, err := bio.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")

View File

@ -90,9 +90,9 @@ importer.
package gc
import (
"bufio"
"bytes"
"cmd/compile/internal/big"
"cmd/internal/bio"
"encoding/binary"
"fmt"
"sort"
@ -124,7 +124,7 @@ const exportVersion = "v0"
const exportInlined = true // default: true
type exporter struct {
out *bio.Writer
out *bufio.Writer
pkgIndex map[*Pkg]int
typIndex map[*Type]int
inlined []*Func
@ -136,7 +136,7 @@ type exporter struct {
}
// export writes the exportlist for localpkg to out and returns the number of bytes written.
func export(out *bio.Writer, trace bool) int {
func export(out *bufio.Writer, trace bool) int {
p := exporter{
out: out,
pkgIndex: make(map[*Pkg]int),

View File

@ -384,7 +384,7 @@ func dumpexport() {
if debugFormat {
// save a copy of the export data
var copy bytes.Buffer
bcopy := bio.BufWriter(&copy)
bcopy := bufio.NewWriter(&copy)
size = export(bcopy, Debug_export != 0)
bcopy.Flush() // flushing to bytes.Buffer cannot fail
if n, err := bout.Write(copy.Bytes()); n != size || err != nil {
@ -407,7 +407,7 @@ func dumpexport() {
pkgs = savedPkgs
pkgMap = savedPkgMap
} else {
size = export(bout, Debug_export != 0)
size = export(bout.Writer(), Debug_export != 0)
}
exportf("\n$$\n")
} else {

View File

@ -5,6 +5,7 @@
package gc
import (
"bufio"
"cmd/compile/internal/ssa"
"cmd/internal/bio"
"cmd/internal/obj"
@ -288,7 +289,7 @@ var Ctxt *obj.Link
var writearchive int
var bstdout *bio.Writer
var bstdout *bufio.Writer
var Nacl bool

View File

@ -9,7 +9,6 @@ package gc
import (
"bufio"
"cmd/compile/internal/ssa"
"cmd/internal/bio"
"cmd/internal/obj"
"cmd/internal/sys"
"flag"
@ -104,7 +103,7 @@ func Main() {
Ctxt = obj.Linknew(Thearch.LinkArch)
Ctxt.DiagFunc = Yyerror
bstdout = bio.BufWriter(os.Stdout)
bstdout = bufio.NewWriter(os.Stdout)
Ctxt.Bso = bstdout
localpkg = mkpkg("")

View File

@ -51,18 +51,6 @@ func Open(name string) (*Reader, error) {
return &Reader{f: f, r: bufio.NewReader(f)}, nil
}
// BufWriter returns a Writer on top of w.
// TODO(dfc) remove this method and replace caller with bufio.Writer.
func BufWriter(w io.Writer) *Writer {
return &Writer{w: bufio.NewWriter(w)}
}
// BufWriter returns a Reader on top of r.
// TODO(dfc) remove this method and replace caller with bufio.Reader.
func BufReader(r io.Reader) *Reader {
return &Reader{r: bufio.NewReader(r)}
}
func (w *Writer) Write(p []byte) (int, error) {
return w.w.Write(p)
}

View File

@ -31,7 +31,7 @@
package obj
import (
"cmd/internal/bio"
"bufio"
"cmd/internal/sys"
)
@ -629,7 +629,7 @@ type Link struct {
Flag_shared int32
Flag_dynlink bool
Flag_optimize bool
Bso *bio.Writer
Bso *bufio.Writer
Pathname string
Goroot string
Goroot_final string

View File

@ -241,7 +241,7 @@ const (
var (
headstring string
// buffered output
Bso *bio.Writer
Bso *bufio.Writer
)
// TODO(dfc) outBuf duplicates bio.Writer

View File

@ -31,7 +31,7 @@
package ld
import (
"cmd/internal/bio"
"bufio"
"cmd/internal/sys"
"debug/elf"
"fmt"
@ -165,8 +165,7 @@ type Link struct {
Headtype int
Arch *sys.Arch
Debugvlog int32
Bso *bio.Writer
Bso *bufio.Writer
Windows int32
Goroot string

View File

@ -31,7 +31,7 @@
package ld
import (
"cmd/internal/bio"
"bufio"
"cmd/internal/obj"
"cmd/internal/sys"
"flag"
@ -46,7 +46,7 @@ var (
)
func Ldmain() {
Bso = bio.BufWriter(os.Stdout)
Bso = bufio.NewWriter(os.Stdout)
Ctxt = linknew(SysArch)
Ctxt.Diag = Diag