Skip to content

Commit

Permalink
rename WriteTo to Write
Browse files Browse the repository at this point in the history
  • Loading branch information
depp committed Apr 14, 2019
1 parent fc78484 commit ef44c4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ func mainE() error {
return err
}
defer fp.Close()
if _, err := prog.WriteTo(fp); err != nil {
if err := prog.Write(fp); err != nil {
return err
}
return fp.Close() // Double-close is OK
Expand Down
13 changes: 5 additions & 8 deletions module/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 225,12 @@ func (p *Program) dumpBlocks() [][]byte {
return d.data
}

// WriteTo writes the program to a writer.
func (p *Program) WriteTo(w io.Writer) (int64, error) {
var amt int64
// Write writes the program, in LE format.
func (p *Program) Write(w io.Writer) error {
for _, d := range p.dumpBlocks() {
n, err := w.Write(d)
amt = int64(n)
if err != nil {
return amt, err
if _, err := w.Write(d); err != nil {
return err
}
}
return amt, nil
return nil
}

0 comments on commit ef44c4a

Please sign in to comment.