Merge branch 'master' of https://github.com/gogf/gf into gvalid_Example

This commit is contained in:
huangqian
2021-12-05 14:56:50 +08:00
8 changed files with 21 additions and 90 deletions

View File

@ -8,7 +8,7 @@ on:
pull_request:
branches: [master, develop]
env:
GF_DEBUG: 1
GF_DEBUG: 0
jobs:
code-test:

View File

@ -1,50 +0,0 @@
os: linux
arch: arm64-graviton2
language: go
go:
- "1.14.x"
- "1.15.x"
- "1.16.x"
branches:
only:
- master
- develop
- staging
env:
- TZ=Asia/Shanghai GF_DEBUG=1 GO111MODULE=on
services:
- mysql
- redis-server
- postgresql
addons:
postgresql: "9.4"
hosts:
- local
before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
install:
- cat /etc/hosts
before_script:
- find . -name "*.go" | xargs gofmt -w
- git diff --name-only --exit-code || exit 1
- echo "UPDATE mysql.user SET authentication_string=PASSWORD('12345678') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
- psql -c 'create database travis_ci_test;' -U postgres
script:
- GOARCH=386 go test -v ./... || exit 1
- GOARCH=amd64 go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -64,7 +64,7 @@ The `Web` component performance of `GoFrame`, please refer to third-party projec
- [ZTE](https://www.zte.com.cn/china/)
- [Ant Financial Services](https://www.antfin.com/)
- [VIVO](https://www.vivo.com/)
- [MedLinker](https://www.vivo.com/)
- [MedLinker](https://www.medlinker.com/)
- [KuCoin](https://www.kucoin.io/)
- [LeYouJia](https://www.leyoujia.com/)
- [IGG](https://igg.com)

View File

@ -2159,13 +2159,17 @@ func Test_Model_FieldsEx(t *testing.T) {
}
func Test_Model_FieldsEx_WithReservedWords(t *testing.T) {
table := "fieldsex_test_table"
sqlTpcPath := gdebug.TestDataPath("reservedwords_table_tpl.sql")
if _, err := db.Exec(ctx, fmt.Sprintf(gfile.GetContents(sqlTpcPath), table)); err != nil {
gtest.Error(err)
}
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
var (
table = "fieldsex_test_table"
sqlTpcPath = gdebug.TestDataPath("reservedwords_table_tpl.sql")
sqlContent = gfile.GetContents(sqlTpcPath)
)
t.AssertNE(sqlContent, "")
if _, err := db.Exec(ctx, fmt.Sprintf(sqlContent, table)); err != nil {
t.AssertNil(err)
}
defer dropTable(table)
_, err := db.Model(table).FieldsEx("content").One()
t.AssertNil(err)
})

View File

@ -14,8 +14,6 @@ import (
"reflect"
"runtime"
"strings"
"github.com/gogf/gf/v2/internal/utils"
)
const (
@ -35,7 +33,7 @@ func init() {
goRootForFilter = strings.Replace(goRootForFilter, "\\", "/", -1)
}
// Initialize internal package variable: selfPath.
selfPath, _ := exec.LookPath(os.Args[0])
selfPath, _ = exec.LookPath(os.Args[0])
if selfPath != "" {
selfPath, _ = filepath.Abs(selfPath)
}
@ -69,7 +67,7 @@ func CallerWithFilter(filter string, skip ...int) (function string, path string,
pc, file, line, ok = runtime.Caller(i)
}
if ok {
function := ""
function = ""
if fn := runtime.FuncForPC(pc); fn == nil {
function = "unknown"
} else {
@ -102,14 +100,8 @@ func callerFromIndex(filters []string) (pc uintptr, file string, line int, index
if filtered {
continue
}
if !utils.IsDebugEnabled() {
if strings.Contains(file, utils.StackFilterKeyForGoFrame) {
continue
}
} else {
if strings.Contains(file, stackFilterKey) {
continue
}
if strings.Contains(file, stackFilterKey) {
continue
}
if index > 0 {
index--

View File

@ -11,8 +11,6 @@ import (
"fmt"
"runtime"
"strings"
"github.com/gogf/gf/v2/internal/utils"
)
// PrintStack prints to standard error the stack trace returned by runtime.Stack.
@ -82,14 +80,8 @@ func StackWithFilters(filters []string, skip ...int) string {
continue
}
if !utils.IsDebugEnabled() {
if strings.Contains(file, utils.StackFilterKeyForGoFrame) {
continue
}
} else {
if strings.Contains(file, stackFilterKey) {
continue
}
if strings.Contains(file, stackFilterKey) {
continue
}
if fn := runtime.FuncForPC(pc); fn == nil {

View File

@ -15,7 +15,6 @@ import (
"strings"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/internal/utils"
)
// Error is custom error for additional features.
@ -201,14 +200,8 @@ func formatSubStack(st stack, buffer *bytes.Buffer) {
if fn := runtime.FuncForPC(p - 1); fn != nil {
file, line := fn.FileLine(p - 1)
// Custom filtering.
if !utils.IsDebugEnabled() {
if strings.Contains(file, utils.StackFilterKeyForGoFrame) {
continue
}
} else {
if strings.Contains(file, stackFilterKeyLocal) {
continue
}
if strings.Contains(file, stackFilterKeyLocal) {
continue
}
// Avoid stack string like "`autogenerated`"
if strings.Contains(file, "<") {

View File

@ -16,7 +16,7 @@ const (
// StackFilterKeyForGoFrame is the stack filtering key for all GoFrame module paths.
// Eg: .../pkg/mod/github.com/gogf/gf/v2@v2.0.0-20211011134327-54dd11f51122/debug/gdebug/gdebug_caller.go
StackFilterKeyForGoFrame = "github.com/gogf/gf/v"
StackFilterKeyForGoFrame = "github.com/gogf/gf/"
)
var (