Check for nil interface correctly

This commit is contained in:
Nikita Tokarchuk
2020-03-24 21:26:28 +01:00
parent 9f647ca094
commit 6111341a3c
5 changed files with 59 additions and 3 deletions
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
"github.com/mainnika/mongox-go-driver/v2/mongox"
"github.com/mainnika/mongox-go-driver/v2/mongox/utils"
)
// GetID returns source document id
@@ -62,7 +63,7 @@ func getObjectOrPanic(source mongox.JSONBased) (id primitive.D) {
func getInterfaceOrPanic(source mongox.InterfaceBased) (id interface{}) {
id = source.GetID()
if id != nil {
if !utils.IsNil(id) {
return id
}