comment updates

This commit is contained in:
john
2019-07-07 09:47:33 +08:00
parent b439aedce5
commit 691baf5c16
5 changed files with 23 additions and 94 deletions

View File

@ -22,7 +22,8 @@ import (
)
const (
gDEFAULT_DEBUG_SQL_LENGTH = 1000 // 默认调试模式下记录的SQL条数
// 默认调试模式下记录的SQL条数
gDEFAULT_DEBUG_SQL_LENGTH = 1000
)
// 获取最近一条执行的sql

View File

@ -18,7 +18,6 @@ func IsEmpty(value interface{}) bool {
if value == nil {
return true
}
// 优先通过断言来进行常用类型判断
switch value := value.(type) {
case int:
return value == 0

View File

@ -15,8 +15,8 @@ import (
)
var (
// 同时支持valid和gvalid标签优先使用valid
structTagPriority = []string{"valid", "gvalid"}
// 同时支持gvalid和valid标签优先使用gvalid
structTagPriority = []string{"gvalid", "valid"}
)
// 校验struct对象属性object参数也可以是一个指向对象的指针返回值同CheckMap方法。

View File

@ -105,7 +105,7 @@ func Test_CheckStruct_With_Inherit(t *testing.T) {
Pass Pass
}
user := &User{
Name: "",
Name: "john",
Pass: Pass{
Pass1: "1",
Pass2: "2",

View File

@ -1,98 +1,27 @@
package main
import (
<<<<<<< HEAD
<<<<<<< HEAD
"fmt"
"github.com/pkg/errors"
"github.com/gogf/gf/g/errors/gerror"
)
func Test1() error {
return gerror.New("test")
}
func Test2() error {
return gerror.Wrap(Test1(), "error test1")
}
type stackTracer interface {
StackTrace() errors.StackTrace
}
func main() {
err := Test2()
//fmt.Printf("%+v", err)
//fmt.Println("==============")
fmt.Println(gerror.Stack(err))
return
type causer interface {
Cause() error
}
for err != nil {
cause, ok := err.(causer)
if !ok {
fmt.Println("ERROR:", err)
if err, ok := err.(stackTracer); ok {
for _, f := range err.StackTrace() {
fmt.Printf("%+s:%d\n", f, f)
}
}
break
}
fmt.Println("ERROR:", err)
if err, ok := err.(stackTracer); ok {
for _, f := range err.StackTrace() {
fmt.Printf("%+s:%d\n", f, f)
}
}
fmt.Println()
err = cause.Cause()
}
//err, ok := Test2().(stackTracer)
//if !ok {
// panic("oops, err does not implement stackTracer")
//}
//
//st := err.StackTrace()
//fmt.Printf("%+v\n", st)
//fmt.Println()
//fmt.Printf("%+v\n", Test2())
=======
"github.com/gogf/gf/g/os/glog"
=======
"fmt"
>>>>>>> d0fe2d2f75a91f44d59969bb25fda3729eabcdde
"github.com/gogf/gf/g"
"github.com/gogf/gf/g/util/gvalid"
)
type User struct {
Uid int
Name string
}
func main() {
<<<<<<< HEAD
TestCache()
>>>>>>> c90ed0d4242527435a3b4c9d7c27742d29c9aaa1
=======
if r, err := g.DB().Table("user").Where("uid=?", 1).One(); r != nil {
u := new(User)
if err := r.ToStruct(u); err == nil {
fmt.Println(" uid:", u.Uid)
fmt.Println("name:", u.Name)
} else {
fmt.Println(err)
}
} else if err != nil {
fmt.Println(err)
type Pass struct {
Pass1 string `valid:"password1@required|same:password2#请输入您的密码|您两次输入的密码不一致"`
Pass2 string `valid:"password2@required|same:password1#请再次输入您的密码|您两次输入的密码不一致"`
}
>>>>>>> d0fe2d2f75a91f44d59969bb25fda3729eabcdde
type User struct {
Id int
Name string `valid:"name@required#请输入您的姓名"`
Pass Pass
}
user := &User{
Name: "john",
Pass: Pass{
Pass1: "1",
Pass2: "2",
},
}
err := gvalid.CheckStruct(user, nil)
g.Dump(err.Maps())
}