go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit f322102e49b4c8f2a00679aee9428faf3c4e2241
parent df0eec0f9617c615c85175de10694fdc2bf4346e
Author: lash <dev@holbrook.no>
Date:   Wed, 28 Aug 2024 02:04:35 +0100

Add language element to gdbm example

Diffstat:
Mresource/gdbm.go | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/resource/gdbm.go b/resource/gdbm.go @@ -3,7 +3,6 @@ package resource import ( "context" "fmt" - "log" gdbm "github.com/graygnuorg/go-gdbm" "git.defalsify.org/vise.git/lang" @@ -41,10 +40,15 @@ func(dbr *gdbmResource) GetTemplate(ctx context.Context, sym string) (string, er ln = v.(lang.Language) } k := ToDbKey(FSRESOURCETYPE_TEMPLATE, sym, &ln) - log.Printf("db fetch %x for %s", k, sym) r, err := dbr.db.Fetch(k) if err != nil { - return "", err + if err.(*gdbm.GdbmError).Is(gdbm.ErrItemNotFound) { + k = ToDbKey(FSRESOURCETYPE_TEMPLATE, sym, nil) + r, err = dbr.db.Fetch(k) + if err != nil { + return "", err + } + } } return string(r), nil } @@ -64,7 +68,6 @@ func(dbr *gdbmResource) GetMenu(ctx context.Context, sym string) (string, error) k := ToDbKey(FSRESOURCETYPE_TEMPLATE, msym, &ln) r, err := dbr.db.Fetch(k) if err != nil { - log.Printf("fetch %x", k) if err.(*gdbm.GdbmError).Is(gdbm.ErrItemNotFound) { return sym, nil }