From 9d2d2c73bb0d9e8e1fc170ac78c5d270b44981ce Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Tue, 6 May 2025 12:52:59 +0000 Subject: [PATCH] fix the crash due to wrong reflect type usage it requires to use the type of elem instead of the slice itself fix crash trace like goroutine 115 [running]: log.Panicf({0x9aa7f4?, 0x0?}, {0xc000507e48?, 0xd95210?, 0x0?}) /usr/local/go/src/log/log.go:439 +0x65 github.com/Prabhjot-Sethi/core/db.(*mongoCollection).Watch.func1.2() /home/core/go/pkg/mod/github.com/!prabhjot-!sethi/core@v0.0.0-20250504230306-35d0b36d9034/db/mongo.go:247 +0x7d github.com/Prabhjot-Sethi/core/db.(*mongoCollection).Watch.func1() /home/core/go/pkg/mod/github.com/!prabhjot-!sethi/core@v0.0.0-20250504230306-35d0b36d9034/db/mongo.go:299 +0x3c2 created by github.com/Prabhjot-Sethi/core/db.(*mongoCollection).Watch in goroutine 1 /home/core/go/pkg/mod/github.com/!prabhjot-!sethi/core@v0.0.0-20250504230306-35d0b36d9034/db/mongo.go:232 +0x158 Signed-off-by: Prabhjot Singh Sethi --- table/generic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/generic.go b/table/generic.go index 6b73f73..c9dd7ab 100644 --- a/table/generic.go +++ b/table/generic.go @@ -27,7 +27,7 @@ func (t *Table[K, E]) Initialize(col db.StoreCollection) error { return errors.Wrapf(errors.AlreadyExists, "Table is already initialized") } var key [0]K - kType := reflect.TypeOf(key) + kType := reflect.TypeOf(key).Elem() if kType.Kind() != reflect.Pointer { kType = reflect.PointerTo(kType) }