From ac0c43cb43a652ccfa0a649f7d4bce56fed72a76 Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 3 Jan 2025 17:18:23 +0000 Subject: [PATCH 1/2] Factor out formatting method --- devtools/store/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/devtools/store/main.go b/devtools/store/main.go index 8bd4d16..dfb9089 100644 --- a/devtools/store/main.go +++ b/devtools/store/main.go @@ -25,6 +25,15 @@ func init() { } +func formatItem(k []byte, v []byte) (string, error) { + o, err := debug.FromKey(k) + if err != nil { + return "", err + } + s := fmt.Sprintf("%vValue: %v\n\n", o, string(v)) + return s, nil +} + func main() { config.LoadConfig() @@ -64,12 +73,12 @@ func main() { if k == nil { break } - o, err := debug.FromKey(k) + r, err := formatItem(k, v) if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) + fmt.Fprintf(os.Stderr, "format db item error: %v", err) os.Exit(1) } - fmt.Printf("%vValue: %v\n\n", o, string(v)) + fmt.Printf(r) } err = store.Close() From daec816a3e0ba47629f6ee400ea7b5fe4cce51d5 Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 3 Jan 2025 17:21:52 +0000 Subject: [PATCH 2/2] Move store devtools location --- devtools/store/{ => dump}/main.go | 0 devtools/{gen => store/generate}/main.go | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename devtools/store/{ => dump}/main.go (100%) rename devtools/{gen => store/generate}/main.go (100%) diff --git a/devtools/store/main.go b/devtools/store/dump/main.go similarity index 100% rename from devtools/store/main.go rename to devtools/store/dump/main.go diff --git a/devtools/gen/main.go b/devtools/store/generate/main.go similarity index 100% rename from devtools/gen/main.go rename to devtools/store/generate/main.go