summaryrefslogtreecommitdiff
path: root/spew/dump.go
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2013-03-11 18:15:28 -0500
committerDave Collins <[email protected]>2013-03-11 18:15:28 -0500
commit3a62f585a795096661480fd3eed87a505dac5d09 (patch)
tree29ae7bb27a0aecb223b2f9207feee7651f5c3667 /spew/dump.go
parent9b87fb3e12f244b6e1d4575c39aeb2761deb5f61 (diff)
Add support for Sdump.
This commit adds a function named Sdump which works exactly like Dump and Fdump except it returns the formatted output as a string. This serves the same purpose as the the Sprint* family of functions.
Diffstat (limited to 'spew/dump.go')
-rw-r--r--spew/dump.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/spew/dump.go b/spew/dump.go
index bf61419..7286241 100644
--- a/spew/dump.go
+++ b/spew/dump.go
@@ -363,6 +363,14 @@ func Fdump(w io.Writer, a ...interface{}) {
fdump(&Config, w, a...)
}
+// Sdump returns a string with the passed arguments formatted exactly the same
+// as Dump.
+func Sdump(a ...interface{}) string {
+ var buf bytes.Buffer
+ fdump(&Config, &buf, a...)
+ return buf.String()
+}
+
/*
Dump displays the passed parameters to standard out with newlines, customizable
indentation, and additional debug information such as complete types and all