add __dir__ function for maps

This commit is contained in:
2023-06-19 12:32:51 +01:00
parent dc2e62bbdb
commit 3f048ce645
4 changed files with 36 additions and 5 deletions

View File

@@ -76,7 +76,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
}
case anymap:
if len(x) == 0 {
return "{}"
return "<>"
}
keys := make([]any, len(x))
sort.Slice(keys, func(i, j int) bool {
@@ -107,7 +107,7 @@ func anyToArgon(x any, quote bool, simplify bool, depth int, indent int, colored
}
output = append(output, keyval+": "+anyToArgon(x[key], true, true, depth-1, indent+1, colored, plain))
}
return "{" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + "}"
return "<" + maybenewline + (strings.Repeat(" ", (indent+1)*plain)) + strings.Join(output, ","+maybenewline+(strings.Repeat(" ", (indent+1)*plain))) + maybenewline + (strings.Repeat(" ", indent*plain)) + ">"
case []any:
singleline := len(x) <= 3
output := []string{}