new type LinkedList, preliminary implementation

This commit is contained in:
2026-05-17 22:43:27 +02:00
parent 9efdeffcac
commit 84b255a51b
12 changed files with 273 additions and 208 deletions
+16 -1
View File
@@ -4,7 +4,10 @@
// formatter.go
package kern
import "fmt"
import (
"fmt"
"strings"
)
type FmtOpt uint32 // lower 16 bits hold a bit-mask, higher 16 bits hold an indentation number
@@ -46,6 +49,18 @@ type Formatter interface {
ToString(options FmtOpt) string
}
func Format(sb *strings.Builder, item any, opt FmtOpt) {
if s, ok := item.(string); ok {
sb.WriteByte('"')
sb.WriteString(s)
sb.WriteByte('"')
} else if formatter, ok := item.(Formatter); ok {
sb.WriteString(formatter.ToString(opt))
} else {
fmt.Fprintf(sb, "%v", item)
}
}
func GetFormatted(v any, opt FmtOpt) (text string) {
if v == nil {
text = "(nil)"