-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.go
More file actions
42 lines (38 loc) · 810 Bytes
/
dump.go
File metadata and controls
42 lines (38 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package env
import (
"github.com/goforj/godump"
"io"
"os"
)
var dumpWriter io.Writer = os.Stdout
// setDumpWriter allows tests to redirect dump output.
// Not exported — production code never needs this.
func setDumpWriter(w io.Writer) {
dumpWriter = w
}
// Dump is a convenience function that calls godump.Dump.
// @group Debugging
// @behavior readonly
//
// Example: integers
//
// nums := []int{1, 2, 3}
// env.Dump(nums)
// // #[]int [
// // 0 => 1 #int
// // 1 => 2 #int
// // 2 => 3 #int
// // ]
//
// Example: multiple values
//
// env.Dump("status", map[string]int{"ok": 1, "fail": 0})
// // #string "status"
// // #map[string]int [
// // "fail" => 0 #int
// // "ok" => 1 #int
// // ]
func Dump(vs ...any) {
d := godump.NewDumper(godump.WithWriter(dumpWriter))
d.Dump(vs...)
}