From 0123dd45094295fade41e13550cd305eb5e3a848 Mon Sep 17 00:00:00 2001 From: Jacky Date: Fri, 12 Jan 2024 18:09:22 +0900 Subject: [PATCH] fix: ignore .gen.go suffix in logger to get the real caller when using gen #6697 (#6785) --- utils/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/utils.go b/utils/utils.go index c8fec5b0..a4d8ac25 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -35,7 +35,8 @@ func FileWithLineNum() string { // the second caller usually from gorm internal, so set i start from 2 for i := 2; i < 15; i++ { _, file, line, ok := runtime.Caller(i) - if ok && (!strings.HasPrefix(file, gormSourceDir) || strings.HasSuffix(file, "_test.go")) { + if ok && (!strings.HasPrefix(file, gormSourceDir) || strings.HasSuffix(file, "_test.go")) && + !strings.HasSuffix(file, ".gen.go") { return file + ":" + strconv.FormatInt(int64(line), 10) } }