From f2d6ea1a897f858fc8a3aa283f6e25c2f1ba5df6 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Thu, 13 Oct 2022 15:13:25 +0800 Subject: [PATCH] feat: add interface errNotExist --- models/db/error.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/db/error.go b/models/db/error.go index 65572299436a6..d52ddcabee500 100644 --- a/models/db/error.go +++ b/models/db/error.go @@ -48,9 +48,15 @@ type ErrNotExist struct { ID int64 } +type errNotExist interface { + isErrNotExist() +} + +func (err ErrNotExist) isErrNotExist() {} + // IsErrNotExist checks if an error is an ErrNotExist func IsErrNotExist(err error) bool { - _, ok := err.(ErrNotExist) + _, ok := err.(errNotExist) return ok }