optimize gormSourceDir replace

This commit is contained in:
daheige 2021-05-26 22:18:32 +08:00
parent ac722c16f9
commit 942a65f5e4

View File

@ -4,7 +4,6 @@ import (
"database/sql/driver" "database/sql/driver"
"fmt" "fmt"
"reflect" "reflect"
"regexp"
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
@ -15,7 +14,7 @@ var gormSourceDir string
func init() { func init() {
_, file, _, _ := runtime.Caller(0) _, file, _, _ := runtime.Caller(0)
gormSourceDir = regexp.MustCompile(`utils.utils\.go`).ReplaceAllString(file, "") gormSourceDir = strings.Replace(file, `utils.utils.go`, "", -1)
} }
func FileWithLineNum() string { func FileWithLineNum() string {