Skip to content

Commit

Permalink
make "Dump" stdoutput atomic (non-interleaved)
Browse files Browse the repository at this point in the history
  • Loading branch information
reinerRubin committed Jul 17, 2019
1 parent d8f796a commit 1b004c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions spew/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"fmt"
"io"
"os"
)

// ConfigState houses the configuration options used by spew to format and
Expand Down Expand Up @@ -271,7 +270,9 @@ See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func (c *ConfigState) Dump(a ...interface{}) {
fdump(c, os.Stdout, a...)
var buf bytes.Buffer
fdump(c, &buf, a...)
fmt.Print(buf.String())
}

// Sdump returns a string with the passed arguments formatted exactly the same
Expand Down
5 changes: 3 additions & 2 deletions spew/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/hex"
"fmt"
"io"
"os"
"reflect"
"regexp"
"strconv"
Expand Down Expand Up @@ -505,5 +504,7 @@ See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func Dump(a ...interface{}) {
fdump(&Config, os.Stdout, a...)
var buf bytes.Buffer
fdump(&Config, &buf, a...)
fmt.Print(buf.String())
}

0 comments on commit 1b004c6

Please sign in to comment.