mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
doc: add docment and playground demo for v2.1.19
This commit is contained in:
1 parent
52ea64bc33
commit
fcb3b97b45
10 files changed
+49
-16
No files matched your search
@@ -48,14 +48,14 @@ func Comma[T constraints.Float | constraints.Integer | string](value T, symbol s
|
||||
}
|
||||
|
||||
// Pretty data to JSON string.
|
||||
// Play: todo
|
||||
// Play: https://go.dev/play/p/YsciGj3FH2x
|
||||
func Pretty(v any) (string, error) {
|
||||
out, err := json.MarshalIndent(v, "", " ")
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
// PrettyToWriter pretty encode data to writer.
|
||||
// Play: todo
|
||||
// Play: https://go.dev/play/p/LPLZ3lDi5ma
|
||||
func PrettyToWriter(v any, out io.Writer) error {
|
||||
enc := json.NewEncoder(out)
|
||||
enc.SetIndent("", " ")
|
||||
|
||||
Reference in new issue
Block a user