1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-15 10:12:29 +08:00

doc: add docment and playground demo for v2.1.19

This commit is contained in:
dudaodong
2023-04-18 15:21:03 +08:00
parent 52ea64bc33
commit fcb3b97b45
10 changed files with 49 additions and 16 deletions

View File

@@ -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("", " ")