我正在嘗試對 dynamoDb 中創建的表中的條目進行分頁是否有檢查表項是否已超出。例如,如果我調用從表中獲取項目,我會收到以下錯誤PANIC: runtime error: invalid memory address or nil pointer dereferencegoroutine 51 [running]:github.com/urfave/negroni.(*Recovery).ServeHTTP.func1(0xdfae028, 0xc000186028, 0xc0002162d0, 0xc000154200) /Users/hammadali/go/pkg/mod/github.com/urfave/[email protected]/recovery.go:159 +0xcbpanic(0x498ea20, 0x51f4410) /usr/local/Cellar/go/1.14.5/libexec/src/runtime/panic.go:969 +0x166github.com/prohousing-as/ph-supplier-service/application.(*SupplierService).GetAllSuppliers(0xc0002cc300, 0xc00002a270, 0x24, 0xbb8, 0xc0004403e0, 0x0, 0x0) /Users/hammadali/source/ph-supplier-service/application/supplier_service.go:41 +0x330github.com/prohousing-as/ph-supplier-service/ui.(*SupplierController).GetAllSupplier(0xc000526ed0, 0xdfae028, 0xc000186028, 0xc0003be300) /Users/hammadali/source/ph-supplier-service/ui/supplier_controller.go:40 +0x139net/http.HandlerFunc.ServeHTTP(0xc000527170, 0xdfae028, 0xc000186028, 0xc0003be300) /usr/local/Cellar/go/1.14.5/libexec/src/net/http/server.go:2041 +0x44github.com/gorilla/mux.(*Router).ServeHTTP(0xc0002e40c0, 0xdfae028, 0xc000186028, 0xc0003be100) /Users/hammadali/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0xe2獲取所有項目的函數// fetches the items from dynamoDb and stores it in resres, err := s.SupplierRepo.GetAllSupplier(uuid, limit) if err != nil { fmt.Println("from application: ", err) return nil, err } item := &domain.SupplierTableItems{} all := &domain.AllSupplierItems{} // Looping over the result and appending it on the list for _, i := range res.Items { err = dynamodbattribute.UnmarshalMap(i, item) all.Collection = append(all.Collection, *item) if err != nil { fmt.Println(err) } } // storing lastEvaluatedKey for pagination all.LastEvaluatedKey = *res.LastEvaluatedKey["uuid"].S return all, nil無論如何要檢查為獲取項目所做的調用是否超過了表條目并僅提供剩余的條目數。
- 1 回答
- 0 關注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消