mirror of
https://gitee.com/johng/gf
synced 2026-06-08 18:47:45 +08:00
Compare commits
13 Commits
contrib/dr
...
v2.2.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 4553f90a83 | |||
| ef7fec7e24 | |||
| 0a76b9c61b | |||
| fbeb8f81ac | |||
| 62af4f1c2c | |||
| ed43efe4fb | |||
| 1cb42c32e3 | |||
| 628b454ebc | |||
| 38a858d7d3 | |||
| 83b92ddfa4 | |||
| 7cd415b1df | |||
| d2113b4d23 | |||
| d445987f95 |
5
.github/workflows/gf.yml
vendored
5
.github/workflows/gf.yml
vendored
@ -127,6 +127,11 @@ jobs:
|
||||
ports:
|
||||
- 5236:5236
|
||||
|
||||
zookeeper:
|
||||
image: loads/zookeeper:3.8
|
||||
ports:
|
||||
- 2181:2181
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ "1.15", "1.16", "1.17", "1.18" ]
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,4 +17,5 @@ cbuild
|
||||
cmd/gf/main
|
||||
cmd/gf/gf
|
||||
go.work
|
||||
go.work.sum
|
||||
temp/
|
||||
|
||||
@ -5,6 +5,7 @@ go 1.18
|
||||
require (
|
||||
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.1.0
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.1.0
|
||||
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.1.0
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.1.0
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.1.0
|
||||
github.com/gogf/gf/v2 v2.2.2
|
||||
@ -35,6 +36,7 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
|
||||
github.com/sijms/go-ora/v2 v2.4.20 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
@ -53,6 +55,7 @@ require (
|
||||
replace (
|
||||
github.com/gogf/gf/contrib/drivers/mssql/v2 => ../../contrib/drivers/mssql/
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 => ../../contrib/drivers/mysql/
|
||||
github.com/gogf/gf/contrib/drivers/oracle/v2 => ../../contrib/drivers/oracle/
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 => ../../contrib/drivers/pgsql/
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 => ../../contrib/drivers/sqlite/
|
||||
github.com/gogf/gf/v2 => ../../
|
||||
|
||||
@ -94,6 +94,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/sijms/go-ora/v2 v2.4.20 h1:9e3z7VLBQXRAHGiIda1GEFtRhfxata0LghyMZqvLKew=
|
||||
github.com/sijms/go-ora/v2 v2.4.20/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
|
||||
@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
_ "github.com/gogf/gf/contrib/drivers/mssql/v2"
|
||||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||
_ "github.com/gogf/gf/contrib/drivers/oracle/v2"
|
||||
_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
||||
_ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -119,20 +119,13 @@ func (s serviceInstall) Run(ctx context.Context) (err error) {
|
||||
dstPath := paths[selectedID]
|
||||
|
||||
// Install the new binary.
|
||||
mlog.Debugf(`copy file from "%s" to "%s"`, gfile.SelfPath(), dstPath.filePath)
|
||||
err = gfile.CopyFile(gfile.SelfPath(), dstPath.filePath)
|
||||
if err != nil {
|
||||
mlog.Printf("install gf binary to '%s' failed: %v", dstPath.dirPath, err)
|
||||
mlog.Printf("you can manually install gf by copying the binary to folder: %s", dstPath.dirPath)
|
||||
} else {
|
||||
mlog.Printf("gf binary is successfully installed to: %s", dstPath.dirPath)
|
||||
}
|
||||
|
||||
// Uninstall the old binary.
|
||||
for _, path := range paths {
|
||||
// Do not delete myself.
|
||||
if path.filePath != "" && path.filePath != dstPath.filePath && gfile.SelfPath() != path.filePath {
|
||||
_ = gfile.Remove(path.filePath)
|
||||
}
|
||||
mlog.Printf("gf binary is successfully installed to: %s", dstPath.filePath)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ func Test_Model_Raw(t *testing.T) {
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Raw(fmt.Sprintf("select id from %s ", table)).Count()
|
||||
t.Assert(count, 10)
|
||||
t.Assert(count, int64(10))
|
||||
t.AssertNil(err)
|
||||
})
|
||||
|
||||
@ -104,7 +104,7 @@ func Test_Model_Insert(t *testing.T) {
|
||||
}).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
value, err := db.Model(table).Fields("passport").Where("id=3").Value() //model value
|
||||
value, err := db.Model(table).Fields("passport").Where("id=3").Value() // model value
|
||||
t.AssertNil(err)
|
||||
t.Assert(value.String(), "t3")
|
||||
|
||||
@ -122,7 +122,7 @@ func Test_Model_Insert(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
t.Assert(value.String(), "t4")
|
||||
|
||||
_, err = db.Model(table).Where("id>?", 1).Delete() //model delete
|
||||
_, err = db.Model(table).Where("id>?", 1).Delete() // model delete
|
||||
t.AssertNil(err)
|
||||
|
||||
})
|
||||
@ -150,7 +150,7 @@ func Test_Model_One(t *testing.T) {
|
||||
_, err := db.Model(table).Data(data).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
one, err := db.Model(table).WherePri(1).One() //model one
|
||||
one, err := db.Model(table).WherePri(1).One() // model one
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data.Passport)
|
||||
t.Assert(one["create_time"], data.CreateTime)
|
||||
@ -249,12 +249,12 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
@ -19,8 +22,6 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
"github.com/google/uuid"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -282,9 +283,9 @@ func TestDriverClickhouse_Insert(t *testing.T) {
|
||||
Created time.Time `orm:"created"`
|
||||
}
|
||||
var (
|
||||
insertUrl = "https://goframe.org"
|
||||
total = 0
|
||||
item = insertItem{
|
||||
insertUrl = "https://goframe.org"
|
||||
total int64 = 0
|
||||
item = insertItem{
|
||||
Duration: 1,
|
||||
Url: insertUrl,
|
||||
Created: time.Now(),
|
||||
@ -296,7 +297,7 @@ func TestDriverClickhouse_Insert(t *testing.T) {
|
||||
gtest.AssertNil(err)
|
||||
total, err = connect.Model("visits").Count()
|
||||
gtest.AssertNil(err)
|
||||
gtest.AssertEQ(total, 2)
|
||||
gtest.AssertEQ(total, int64(2))
|
||||
var list []*insertItem
|
||||
for i := 0; i < 50; i++ {
|
||||
list = append(list, &insertItem{
|
||||
@ -311,7 +312,7 @@ func TestDriverClickhouse_Insert(t *testing.T) {
|
||||
gtest.AssertNil(err)
|
||||
total, err = connect.Model("visits").Count()
|
||||
gtest.AssertNil(err)
|
||||
gtest.AssertEQ(total, 102)
|
||||
gtest.AssertEQ(total, int64(102))
|
||||
}
|
||||
|
||||
func TestDriverClickhouse_Insert_Use_Exec(t *testing.T) {
|
||||
@ -466,7 +467,7 @@ func TestDriverClickhouse_NilTime(t *testing.T) {
|
||||
gtest.AssertNil(err)
|
||||
count, err := connect.Model("data_type").Where("Col4", "Inc.").Count()
|
||||
gtest.AssertNil(err)
|
||||
gtest.AssertEQ(count, 10000)
|
||||
gtest.AssertEQ(count, int64(10000))
|
||||
|
||||
data, err := connect.Model("data_type").Where("Col4", "Inc.").One()
|
||||
gtest.AssertNil(err)
|
||||
@ -507,7 +508,7 @@ func TestDriverClickhouse_BatchInsert(t *testing.T) {
|
||||
gtest.AssertNil(err)
|
||||
count, err := connect.Model("data_type").Where("Col2", "ClickHouse").Where("Col3", "Inc").Count()
|
||||
gtest.AssertNil(err)
|
||||
gtest.AssertEQ(count, 10000)
|
||||
gtest.AssertEQ(count, int64(10000))
|
||||
}
|
||||
|
||||
func TestDriverClickhouse_Open(t *testing.T) {
|
||||
|
||||
@ -307,7 +307,7 @@ func Test_Model_Clone(t *testing.T) {
|
||||
result, err := md.Safe(true).Order("id ASC").All()
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
t.Assert(record["ID"].Int(), 3)
|
||||
t.Assert(len(result), 2)
|
||||
t.Assert(result[0]["ID"].Int(), 1)
|
||||
@ -323,42 +323,42 @@ func Test_Model_Safe(t *testing.T) {
|
||||
md := db.Model(table).Safe(false).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe(true).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe().Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md1 := db.Model(table).Safe()
|
||||
md2 := md1.Where("id in (?)", g.Slice{1, 3})
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.All()
|
||||
t.AssertNil(err)
|
||||
@ -380,7 +380,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 1,3
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -395,7 +395,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 4,5,6
|
||||
count, err = md3.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
|
||||
all, err = md3.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -487,7 +487,7 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Count with cache, check internal ctx data feature.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -498,24 +498,24 @@ func Test_Model_Count(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
}
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Fields("distinct id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
// COUNT...LIMIT...
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Page(1, 2).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
|
||||
}
|
||||
@ -1809,7 +1809,7 @@ func Test_Model_Distinct(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id > 1").Distinct().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 9)
|
||||
t.Assert(count, int64(9))
|
||||
})
|
||||
}
|
||||
|
||||
@ -2310,7 +2310,7 @@ func Test_Model_Raw(t *testing.T) {
|
||||
OrderDesc("id").
|
||||
Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 6)
|
||||
t.Assert(count, int64(6))
|
||||
})
|
||||
}
|
||||
|
||||
@ -2398,38 +2398,38 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Where("nickname", "").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Slice where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{1, 2, 3}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Struct Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -2439,7 +2439,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Input struct {
|
||||
@ -2448,7 +2448,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Map Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -2457,7 +2457,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
"nickname": []string{},
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Input struct {
|
||||
@ -2467,7 +2467,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
"id": []int{},
|
||||
}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -581,7 +581,7 @@ func Test_DB_GetCount(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.GetCount(ctx, fmt.Sprintf("SELECT * FROM %s", table))
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -81,20 +81,20 @@ func Test_Master_Slave(t *testing.T) {
|
||||
_, err = masterSlaveDB.Model(table).Data(array).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
var count int
|
||||
var count int64
|
||||
// Auto slave.
|
||||
count, err = masterSlaveDB.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
|
||||
// slave.
|
||||
count, err = masterSlaveDB.Model(table).Slave().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
|
||||
// master.
|
||||
count, err = masterSlaveDB.Model(table).Master().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ func Test_Model_Clone(t *testing.T) {
|
||||
result, err := md.Safe(true).Order("id ASC").All()
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
t.Assert(record["id"].Int(), 3)
|
||||
t.Assert(len(result), 2)
|
||||
t.Assert(result[0]["id"].Int(), 1)
|
||||
@ -478,42 +478,42 @@ func Test_Model_Safe(t *testing.T) {
|
||||
md := db.Model(table).Safe(false).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe(true).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe().Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md1 := db.Model(table).Safe()
|
||||
md2 := md1.Where("id in (?)", g.Slice{1, 3})
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.All()
|
||||
t.AssertNil(err)
|
||||
@ -535,7 +535,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 1,3
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -550,7 +550,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 4,5,6
|
||||
count, err = md3.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
|
||||
all, err = md3.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -701,7 +701,7 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Count with cache, check internal ctx data feature.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -712,24 +712,24 @@ func Test_Model_Count(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
}
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Fields("distinct id,nickname").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
// COUNT...LIMIT...
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Page(1, 2).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -776,7 +776,7 @@ func Test_Model_Count_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.Model(table).Data(g.MapStrAny{
|
||||
@ -795,7 +795,7 @@ func Test_Model_Count_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ func Test_Model_Count_All_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.Model(table).Data(g.MapStrAny{
|
||||
@ -828,7 +828,7 @@ func Test_Model_Count_All_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.Model(table).Data(g.MapStrAny{
|
||||
@ -847,7 +847,7 @@ func Test_Model_Count_All_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -861,7 +861,7 @@ func Test_Model_CountColumn_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).CountColumn("id")
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.Model(table).Data(g.MapStrAny{
|
||||
@ -880,7 +880,7 @@ func Test_Model_CountColumn_WithCache(t *testing.T) {
|
||||
Force: false,
|
||||
}).CountColumn("id")
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -1123,7 +1123,7 @@ func Test_Model_StructsWithOrmTag(t *testing.T) {
|
||||
dbInvalid.GetLogger().(*glog.Logger).SetWriter(buffer)
|
||||
defer dbInvalid.GetLogger().(*glog.Logger).SetWriter(os.Stdout)
|
||||
dbInvalid.Model(table).Order("id asc").Scan(&users)
|
||||
//fmt.Println(buffer.String())
|
||||
// fmt.Println(buffer.String())
|
||||
t.Assert(
|
||||
gstr.Contains(
|
||||
buffer.String(),
|
||||
@ -1986,7 +1986,7 @@ func Test_Model_Page(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
t.Assert(len(all), 3)
|
||||
t.Assert(all[0]["id"], "7")
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -2890,7 +2890,7 @@ func Test_Model_Distinct(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id > 1").Distinct().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 9)
|
||||
t.Assert(count, int64(9))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3636,7 +3636,7 @@ func Test_Model_Increment_Decrement(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 91).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3812,7 +3812,7 @@ func Test_Model_Raw(t *testing.T) {
|
||||
Limit(2).
|
||||
Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 6)
|
||||
t.Assert(count, int64(6))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3900,38 +3900,38 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Where("nickname", "").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Slice where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{1, 2, 3}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Struct Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -3941,7 +3941,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Input struct {
|
||||
@ -3950,7 +3950,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Map Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -3959,7 +3959,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
"nickname": []string{},
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Input struct {
|
||||
@ -3969,7 +3969,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
"id": []int{},
|
||||
}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -4649,12 +4649,12 @@ func Test_Builder_OmitEmptyWhere(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 1).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 0).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
builder := db.Model(table).OmitEmptyWhere().Builder()
|
||||
@ -4662,6 +4662,6 @@ func Test_Builder_OmitEmptyWhere(t *testing.T) {
|
||||
builder.Where("id", 0),
|
||||
).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ func Test_TX_Insert(t *testing.T) {
|
||||
if n, err := tx.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, 2)
|
||||
t.Assert(n, int64(2))
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
@ -180,7 +180,7 @@ func Test_TX_BatchInsert(t *testing.T) {
|
||||
if n, err := db.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, 2)
|
||||
t.Assert(n, int64(2))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -218,7 +218,7 @@ func Test_TX_BatchReplace(t *testing.T) {
|
||||
if n, err := db.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, TableSize)
|
||||
t.Assert(n, int64(TableSize))
|
||||
}
|
||||
if value, err := db.Model(table).Fields("password").Where("id", 2).Value(); err != nil {
|
||||
gtest.Error(err)
|
||||
@ -255,7 +255,7 @@ func Test_TX_BatchSave(t *testing.T) {
|
||||
if n, err := db.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, TableSize)
|
||||
t.Assert(n, int64(TableSize))
|
||||
}
|
||||
|
||||
if value, err := db.Model(table).Fields("password").Where("id", 4).Value(); err != nil {
|
||||
@ -428,7 +428,7 @@ func Test_TX_GetCount(t *testing.T) {
|
||||
if count, err := tx.GetCount("SELECT * FROM " + table); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
gtest.Error(err)
|
||||
@ -674,7 +674,7 @@ func Test_TX_Delete(t *testing.T) {
|
||||
if n, err := db.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, 0)
|
||||
t.Assert(n, int64(0))
|
||||
}
|
||||
|
||||
t.Assert(tx.IsClosed(), true)
|
||||
@ -693,7 +693,7 @@ func Test_TX_Delete(t *testing.T) {
|
||||
if n, err := tx.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, 0)
|
||||
t.Assert(n, int64(0))
|
||||
}
|
||||
if err := tx.Rollback(); err != nil {
|
||||
gtest.Error(err)
|
||||
@ -701,8 +701,8 @@ func Test_TX_Delete(t *testing.T) {
|
||||
if n, err := db.Model(table).Count(); err != nil {
|
||||
gtest.Error(err)
|
||||
} else {
|
||||
t.Assert(n, TableSize)
|
||||
t.AssertNE(n, 0)
|
||||
t.Assert(n, int64(TableSize))
|
||||
t.AssertNE(n, int64(0))
|
||||
}
|
||||
|
||||
t.Assert(tx.IsClosed(), true)
|
||||
@ -1136,6 +1136,6 @@ func Test_Transaction_Method(t *testing.T) {
|
||||
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
}
|
||||
|
||||
@ -9,6 +9,10 @@ package oracle_test
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gmap"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@ -16,9 +20,6 @@ import (
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Test_Model_InnerJoin(t *testing.T) {
|
||||
@ -162,7 +163,7 @@ func TestPage(t *testing.T) {
|
||||
func Test_Model_Insert(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
//db.SetDebug(true)
|
||||
// db.SetDebug(true)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
user := db.Model(table)
|
||||
result, err := user.Data(g.Map{
|
||||
@ -406,7 +407,7 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Count with cache, check internal ctx data feature.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -417,24 +418,24 @@ func Test_Model_Count(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
}
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("ID").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Fields("distinct id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
// COUNT...LIMIT...
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Page(1, 2).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
|
||||
}
|
||||
@ -922,11 +923,11 @@ func Test_Model_Distinct(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id > 1").Distinct().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 9)
|
||||
t.Assert(count, int64(9))
|
||||
})
|
||||
}
|
||||
|
||||
//not support
|
||||
// not support
|
||||
/*
|
||||
func Test_Model_Min_Max(t *testing.T) {
|
||||
table := createInitTable()
|
||||
@ -947,7 +948,7 @@ func Test_Model_Min_Max(t *testing.T) {
|
||||
func Test_Model_HasTable(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
//db.SetDebug(true)
|
||||
// db.SetDebug(true)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.GetCore().HasTable(strings.ToUpper(table))
|
||||
t.Assert(result, true)
|
||||
|
||||
@ -64,7 +64,7 @@ func Test_Model_Insert(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
n, _ = result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
value, err := db.Model(table).Fields("passport").Where("id=3").Value() //model value
|
||||
value, err := db.Model(table).Fields("passport").Where("id=3").Value() // model value
|
||||
t.AssertNil(err)
|
||||
t.Assert(value.String(), "t3")
|
||||
|
||||
@ -83,7 +83,7 @@ func Test_Model_Insert(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
t.Assert(value.String(), "t4")
|
||||
|
||||
result, err = db.Model(table).Where("id>?", 1).Delete() //model delete
|
||||
result, err = db.Model(table).Where("id>?", 1).Delete() // model delete
|
||||
t.AssertNil(err)
|
||||
n, _ = result.RowsAffected()
|
||||
t.Assert(n, 3)
|
||||
@ -112,7 +112,7 @@ func Test_Model_One(t *testing.T) {
|
||||
_, err := db.Model(table).Data(data).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
one, err := db.Model(table).WherePri(1).One() //model one
|
||||
one, err := db.Model(table).WherePri(1).One() // model one
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data.Passport)
|
||||
t.Assert(one["create_time"], data.CreateTime)
|
||||
@ -214,12 +214,12 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -94,6 +94,6 @@ func Test_Raw_Update(t *testing.T) {
|
||||
user := db.Model(table)
|
||||
n, err := user.Where("id", 101).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(n, 1)
|
||||
t.Assert(n, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ func Test_Model_Clone(t *testing.T) {
|
||||
result, err := md.Safe(true).Order("id ASC").All()
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
t.Assert(record["id"].Int(), 3)
|
||||
t.Assert(len(result), 2)
|
||||
t.Assert(result[0]["id"].Int(), 1)
|
||||
@ -468,42 +468,42 @@ func Test_Model_Safe(t *testing.T) {
|
||||
md := db.Model(table).Safe(false).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe(true).Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md := db.Model(table).Safe().Where("id IN(?)", g.Slice{1, 3})
|
||||
count, err := md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
md.Where("id = ?", 1)
|
||||
count, err = md.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
md1 := db.Model(table).Safe()
|
||||
md2 := md1.Where("id in (?)", g.Slice{1, 3})
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.All()
|
||||
t.AssertNil(err)
|
||||
@ -525,7 +525,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 1,3
|
||||
count, err := md2.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
|
||||
all, err := md2.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -540,7 +540,7 @@ func Test_Model_Safe(t *testing.T) {
|
||||
// 4,5,6
|
||||
count, err = md3.Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
|
||||
all, err = md3.Order("id asc").All()
|
||||
t.AssertNil(err)
|
||||
@ -692,7 +692,7 @@ func Test_Model_Count(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Count with cache, check internal ctx data feature.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -703,24 +703,24 @@ func Test_Model_Count(t *testing.T) {
|
||||
Force: false,
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
}
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Fields("distinct id").Where("id>8").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 2)
|
||||
t.Assert(count, int64(2))
|
||||
})
|
||||
// COUNT...LIMIT...
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Page(1, 2).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -1819,7 +1819,7 @@ func Test_Model_Page(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
t.Assert(len(all), 3)
|
||||
t.Assert(all[0]["id"], "7")
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
@ -2369,7 +2369,7 @@ func Test_Model_Distinct(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id > 1").Distinct().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 9)
|
||||
t.Assert(count, int64(9))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3171,7 +3171,7 @@ func Test_Model_Increment_Decrement(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 91).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
t.Assert(count, int64(1))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3202,7 +3202,7 @@ func Test_Model_Raw(t *testing.T) {
|
||||
Limit(2).
|
||||
Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 6)
|
||||
t.Assert(count, int64(6))
|
||||
})
|
||||
}
|
||||
|
||||
@ -3290,38 +3290,38 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", 0).Where("nickname", "").Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Slice where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{1, 2, 3}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 3)
|
||||
t.Assert(count, int64(3))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).OmitEmptyWhere().Where("id", g.Slice{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where("id", g.Slice{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Struct Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -3331,7 +3331,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Input struct {
|
||||
@ -3340,7 +3340,7 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
}
|
||||
count, err := db.Model(table).Where(Input{}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
// Map Where.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -3349,14 +3349,14 @@ func Test_Model_OmitEmptyWhere(t *testing.T) {
|
||||
"nickname": []string{},
|
||||
}).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 0)
|
||||
t.Assert(count, int64(0))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
count, err := db.Model(table).Where(g.Map{
|
||||
"id": []int{},
|
||||
}).OmitEmptyWhere().Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, TableSize)
|
||||
t.Assert(count, int64(TableSize))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
71
contrib/registry/zookeeper/README.MD
Normal file
71
contrib/registry/zookeeper/README.MD
Normal file
@ -0,0 +1,71 @@
|
||||
# GoFrame Etcd Registry
|
||||
|
||||
Use `zookeeper` as service registration and discovery management.
|
||||
|
||||
## Installation
|
||||
```
|
||||
go get -u -v github.com/gogf/gf/contrib/registry/zookeeper/v2
|
||||
```
|
||||
suggested using `go.mod`:
|
||||
```
|
||||
require github.com/gogf/gf/contrib/registry/zookeeper/v2 latest
|
||||
```
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/contrib/registry/zookeeper/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := zookeeper.New([]string{"127.0.0.1:2181"}, zookeeper.WithRootPath("/gogf"))
|
||||
gsvc.SetRegistry(r)
|
||||
|
||||
s := g.Server(`hello.svc`)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
g.Log().Info(r.Context(), `request received`)
|
||||
r.Response.Write(`Hello world`)
|
||||
})
|
||||
s.Run()
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/contrib/registry/zookeeper/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/gsel"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gsvc.SetRegistry(zookeeper.New([]string{"127.0.0.1:2181"},zookeeper.WithRootPath("/gogf")))
|
||||
gsel.SetBuilder(gsel.NewBuilderRoundRobin())
|
||||
|
||||
client := g.Client()
|
||||
for i := 0; i < 100; i++ {
|
||||
res, err := client.Get(gctx.New(), `http://hello.svc/`)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(res.ReadAllString())
|
||||
res.Close()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
`GoFrame zookeeper` is licensed under the [MIT License](../../../LICENSE), 100% free and open-source, forever.
|
||||
|
||||
11
contrib/registry/zookeeper/go.mod
Normal file
11
contrib/registry/zookeeper/go.mod
Normal file
@ -0,0 +1,11 @@
|
||||
module github.com/gogf/gf/contrib/registry/zookeeper/v2
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/go-zookeeper/zk v1.0.3
|
||||
github.com/gogf/gf/v2 v2.2.2
|
||||
golang.org/x/sync v0.1.0
|
||||
)
|
||||
|
||||
replace github.com/gogf/gf/v2 => ../../../
|
||||
172
contrib/registry/zookeeper/go.sum
Normal file
172
contrib/registry/zookeeper/go.sum
Normal file
@ -0,0 +1,172 @@
|
||||
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E=
|
||||
github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg=
|
||||
github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
|
||||
github.com/gogf/gf/v2 v2.2.2 h1:ew4k/VSr/gcPdMZcI8/HZYBYPjB0KOk6bQqA61M8bYE=
|
||||
github.com/gogf/gf/v2 v2.2.2/go.mod h1:thvkyb43RWUu/m05sRm4CbH9r7t7/FrW2M56L9Ystwk=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
|
||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
|
||||
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
|
||||
go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0=
|
||||
go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU=
|
||||
go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o=
|
||||
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 h1:GLw7MR8AfAG2GmGcmVgObFOHXYypgGjnGno25RDwn3Y=
|
||||
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
71
contrib/registry/zookeeper/zookeeper.go
Normal file
71
contrib/registry/zookeeper/zookeeper.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
// Package zookeeper implements service Registry and Discovery using zookeeper.
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"github.com/go-zookeeper/zk"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"golang.org/x/sync/singleflight"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ gsvc.Registry = &Registry{}
|
||||
|
||||
type Content struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
// Option is etcd registry option.
|
||||
type Option func(o *options)
|
||||
|
||||
type options struct {
|
||||
namespace string
|
||||
user string
|
||||
password string
|
||||
}
|
||||
|
||||
// WithRootPath with registry root path.
|
||||
func WithRootPath(path string) Option {
|
||||
return func(o *options) { o.namespace = path }
|
||||
}
|
||||
|
||||
// WithDigestACL with registry password.
|
||||
func WithDigestACL(user string, password string) Option {
|
||||
return func(o *options) {
|
||||
o.user = user
|
||||
o.password = password
|
||||
}
|
||||
}
|
||||
|
||||
// Registry is consul registry
|
||||
type Registry struct {
|
||||
opts *options
|
||||
conn *zk.Conn
|
||||
group singleflight.Group
|
||||
}
|
||||
|
||||
func New(address []string, opts ...Option) *Registry {
|
||||
conn, _, err := zk.Connect(address, time.Second*120)
|
||||
if err != nil {
|
||||
panic(gerror.Wrapf(err,
|
||||
"Error with connect to zookeeper"),
|
||||
)
|
||||
}
|
||||
options := &options{
|
||||
namespace: "/microservices",
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(options)
|
||||
}
|
||||
return &Registry{
|
||||
opts: options,
|
||||
conn: conn,
|
||||
}
|
||||
}
|
||||
71
contrib/registry/zookeeper/zookeeper_discovery.go
Normal file
71
contrib/registry/zookeeper/zookeeper_discovery.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Search is the etcd discovery search function.
|
||||
func (r *Registry) Search(_ context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) {
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(in.Prefix, "/", "-"), "-")
|
||||
instances, err, _ := r.group.Do(prefix, func() (interface{}, error) {
|
||||
serviceNamePath := path.Join(r.opts.namespace, prefix)
|
||||
servicesID, _, err := r.conn.Children(serviceNamePath)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with search the children node under %s",
|
||||
serviceNamePath,
|
||||
)
|
||||
}
|
||||
items := make([]gsvc.Service, 0, len(servicesID))
|
||||
for _, service := range servicesID {
|
||||
servicePath := path.Join(serviceNamePath, service)
|
||||
byteData, _, err := r.conn.Get(servicePath)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with node data which name is %s",
|
||||
servicePath,
|
||||
)
|
||||
}
|
||||
item, err := unmarshal(byteData)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with unmarshal node data to Content",
|
||||
)
|
||||
}
|
||||
svc, err := gsvc.NewServiceWithKV(item.Key, item.Value)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with new service with KV in Content",
|
||||
)
|
||||
}
|
||||
items = append(items, svc)
|
||||
}
|
||||
return items, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with group do",
|
||||
)
|
||||
}
|
||||
return instances.([]gsvc.Service), nil
|
||||
}
|
||||
|
||||
// Watch is the etcd discovery watch function.
|
||||
func (r *Registry) Watch(ctx context.Context, key string) (gsvc.Watcher, error) {
|
||||
return newWatcher(ctx, r.opts.namespace, key, r.conn)
|
||||
}
|
||||
20
contrib/registry/zookeeper/zookeeper_func.go
Normal file
20
contrib/registry/zookeeper/zookeeper_func.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func unmarshal(data []byte) (c *Content, err error) {
|
||||
err = json.Unmarshal(data, &c)
|
||||
return
|
||||
}
|
||||
|
||||
func marshal(c *Content) ([]byte, error) {
|
||||
return json.Marshal(c)
|
||||
}
|
||||
139
contrib/registry/zookeeper/zookeeper_registrar.go
Normal file
139
contrib/registry/zookeeper/zookeeper_registrar.go
Normal file
@ -0,0 +1,139 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-zookeeper/zk"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
)
|
||||
|
||||
// Register registers `service` to Registry.
|
||||
// Note that it returns a new Service if it changes the input Service with custom one.
|
||||
func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Service, error) {
|
||||
var (
|
||||
data []byte
|
||||
err error
|
||||
)
|
||||
if err = r.ensureName(r.opts.namespace, []byte(""), 0); err != nil {
|
||||
return service, gerror.Wrapf(
|
||||
err,
|
||||
"Error Creat node which name is %s",
|
||||
r.opts.namespace,
|
||||
)
|
||||
}
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
|
||||
servicePrefixPath := path.Join(r.opts.namespace, prefix)
|
||||
if err = r.ensureName(servicePrefixPath, []byte(""), 0); err != nil {
|
||||
return service, gerror.Wrapf(
|
||||
err,
|
||||
"Error Creat node which name is %s",
|
||||
servicePrefixPath,
|
||||
)
|
||||
}
|
||||
|
||||
if data, err = marshal(&Content{
|
||||
Key: service.GetKey(),
|
||||
Value: service.GetValue(),
|
||||
}); err != nil {
|
||||
return service, gerror.Wrapf(
|
||||
err,
|
||||
"Error with marshal Content to Json string",
|
||||
)
|
||||
}
|
||||
servicePath := path.Join(servicePrefixPath, service.GetName())
|
||||
if err = r.ensureName(servicePath, data, zk.FlagEphemeral); err != nil {
|
||||
return service, gerror.Wrapf(
|
||||
err,
|
||||
"Error Creat node which name is %s",
|
||||
servicePath,
|
||||
)
|
||||
}
|
||||
go r.reRegister(servicePath, data)
|
||||
return service, nil
|
||||
}
|
||||
|
||||
// Deregister off-lines and removes `service` from the Registry.
|
||||
func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error {
|
||||
ch := make(chan error, 1)
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
|
||||
servicePath := path.Join(r.opts.namespace, prefix, service.GetName())
|
||||
go func() {
|
||||
err := r.conn.Delete(servicePath, -1)
|
||||
ch <- err
|
||||
}()
|
||||
var err error
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = ctx.Err()
|
||||
case err = <-ch:
|
||||
}
|
||||
return gerror.Wrapf(err,
|
||||
"Error with deregister service:%s",
|
||||
service.GetName(),
|
||||
)
|
||||
}
|
||||
|
||||
// ensureName ensure node exists, if not exist, create and set data
|
||||
func (r *Registry) ensureName(path string, data []byte, flags int32) error {
|
||||
exists, stat, err := r.conn.Exists(path)
|
||||
if err != nil {
|
||||
return gerror.Wrapf(err,
|
||||
"Error with check node exist which name is %s",
|
||||
path,
|
||||
)
|
||||
}
|
||||
// ephemeral nodes handling after restart
|
||||
// fixes a race condition if the server crashes without using CreateProtectedEphemeralSequential()
|
||||
if flags&zk.FlagEphemeral == zk.FlagEphemeral {
|
||||
err = r.conn.Delete(path, stat.Version)
|
||||
if err != nil && err != zk.ErrNoNode {
|
||||
return gerror.Wrapf(err,
|
||||
"Error with delete node which name is %s",
|
||||
path,
|
||||
)
|
||||
}
|
||||
exists = false
|
||||
}
|
||||
if !exists {
|
||||
if len(r.opts.user) > 0 && len(r.opts.password) > 0 {
|
||||
_, err = r.conn.Create(path, data, flags, zk.DigestACL(zk.PermAll, r.opts.user, r.opts.password))
|
||||
} else {
|
||||
_, err = r.conn.Create(path, data, flags, zk.WorldACL(zk.PermAll))
|
||||
}
|
||||
if err != nil {
|
||||
return gerror.Wrapf(err,
|
||||
"Error with create node which name is %s",
|
||||
path,
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// reRegister re-register data node info when bad connection recovered
|
||||
func (r *Registry) reRegister(path string, data []byte) {
|
||||
sessionID := r.conn.SessionID()
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
cur := r.conn.SessionID()
|
||||
// sessionID changed
|
||||
if cur > 0 && sessionID != cur {
|
||||
// re-ensureName
|
||||
if err := r.ensureName(path, data, zk.FlagEphemeral); err != nil {
|
||||
return
|
||||
}
|
||||
sessionID = cur
|
||||
}
|
||||
}
|
||||
}
|
||||
138
contrib/registry/zookeeper/zookeeper_watcher.go
Normal file
138
contrib/registry/zookeeper/zookeeper_watcher.go
Normal file
@ -0,0 +1,138 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/go-zookeeper/zk"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"golang.org/x/sync/singleflight"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var _ gsvc.Watcher = (*watcher)(nil)
|
||||
|
||||
var ErrWatcherStopped = errors.New("watcher stopped")
|
||||
|
||||
type watcher struct {
|
||||
ctx context.Context
|
||||
event chan zk.Event
|
||||
conn *zk.Conn
|
||||
cancel context.CancelFunc
|
||||
prefix string
|
||||
nameSpace string
|
||||
group singleflight.Group
|
||||
}
|
||||
|
||||
func newWatcher(ctx context.Context, nameSpace, prefix string, conn *zk.Conn) (*watcher, error) {
|
||||
w := &watcher{
|
||||
conn: conn,
|
||||
event: make(chan zk.Event, 1),
|
||||
nameSpace: nameSpace,
|
||||
prefix: prefix,
|
||||
}
|
||||
w.ctx, w.cancel = context.WithCancel(ctx)
|
||||
go w.watch(w.ctx)
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func (w *watcher) Proceed() ([]gsvc.Service, error) {
|
||||
select {
|
||||
case <-w.ctx.Done():
|
||||
return nil, w.ctx.Err()
|
||||
case e := <-w.event:
|
||||
if e.State == zk.StateDisconnected {
|
||||
return nil, gerror.Wrapf(
|
||||
ErrWatcherStopped,
|
||||
"watcher stopped",
|
||||
)
|
||||
}
|
||||
if e.Err != nil {
|
||||
return nil, e.Err
|
||||
}
|
||||
return w.getServicesByPrefix()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *watcher) getServicesByPrefix() ([]gsvc.Service, error) {
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-")
|
||||
serviceNamePath := path.Join(w.nameSpace, prefix)
|
||||
instances, err, _ := w.group.Do(serviceNamePath, func() (interface{}, error) {
|
||||
servicesID, _, err := w.conn.Children(serviceNamePath)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with search the children node under %s",
|
||||
serviceNamePath,
|
||||
)
|
||||
}
|
||||
items := make([]gsvc.Service, 0, len(servicesID))
|
||||
for _, service := range servicesID {
|
||||
servicePath := path.Join(serviceNamePath, service)
|
||||
byteData, _, err := w.conn.Get(servicePath)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with node data which name is %s",
|
||||
servicePath,
|
||||
)
|
||||
}
|
||||
item, err := unmarshal(byteData)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with unmarshal node data to Content",
|
||||
)
|
||||
}
|
||||
svc, err := gsvc.NewServiceWithKV(item.Key, item.Value)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with new service with KV in Content",
|
||||
)
|
||||
}
|
||||
items = append(items, svc)
|
||||
}
|
||||
return items, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, gerror.Wrapf(
|
||||
err,
|
||||
"Error with group do",
|
||||
)
|
||||
}
|
||||
return instances.([]gsvc.Service), nil
|
||||
}
|
||||
|
||||
func (w *watcher) Close() error {
|
||||
w.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *watcher) watch(ctx context.Context) {
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-")
|
||||
serviceNamePath := path.Join(w.nameSpace, prefix)
|
||||
for {
|
||||
|
||||
if w.conn.State() == zk.StateConnected || w.conn.State() == zk.StateHasSession {
|
||||
// each watch action is only valid once
|
||||
_, _, ch, err := w.conn.ChildrenW(serviceNamePath)
|
||||
if err != nil {
|
||||
w.event <- zk.Event{Err: err}
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
w.event <- <-ch
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
189
contrib/registry/zookeeper/zookeeper_z_test.go
Normal file
189
contrib/registry/zookeeper/zookeeper_z_test.go
Normal file
@ -0,0 +1,189 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/gsvc"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
// TestRegistry TestRegistryManyService
|
||||
func TestRegistry(t *testing.T) {
|
||||
r := New([]string{"127.0.0.1:2181"}, WithRootPath("/gogf"))
|
||||
ctx := context.Background()
|
||||
|
||||
svc := &gsvc.LocalService{
|
||||
Name: "goframe-provider-0-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9000"),
|
||||
}
|
||||
|
||||
s, err := r.Register(ctx, svc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = r.Deregister(ctx, s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRegistryMany TestRegistryManyService
|
||||
func TestRegistryMany(t *testing.T) {
|
||||
r := New([]string{"127.0.0.1:2181"}, WithRootPath("/gogf"))
|
||||
|
||||
svc := &gsvc.LocalService{
|
||||
Name: "goframe-provider-1-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9000"),
|
||||
}
|
||||
svc1 := &gsvc.LocalService{
|
||||
Name: "goframe-provider-2-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9001"),
|
||||
}
|
||||
svc2 := &gsvc.LocalService{
|
||||
Name: "goframe-provider-3-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9002"),
|
||||
}
|
||||
|
||||
s0, err := r.Register(context.Background(), svc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s1, err := r.Register(context.Background(), svc1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s2, err := r.Register(context.Background(), svc2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = r.Deregister(context.Background(), s0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = r.Deregister(context.Background(), s1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = r.Deregister(context.Background(), s2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGetService Test GetService
|
||||
func TestGetService(t *testing.T) {
|
||||
r := New([]string{"127.0.0.1:2181"}, WithRootPath("/gogf"))
|
||||
ctx := context.Background()
|
||||
|
||||
svc := &gsvc.LocalService{
|
||||
Name: "goframe-provider-4-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9000"),
|
||||
}
|
||||
|
||||
s, err := r.Register(ctx, svc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
serviceInstances, err := r.Search(ctx, gsvc.SearchInput{
|
||||
Prefix: s.GetPrefix(),
|
||||
Name: svc.Name,
|
||||
Version: svc.Version,
|
||||
Metadata: svc.Metadata,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, instance := range serviceInstances {
|
||||
g.Log().Info(ctx, instance)
|
||||
}
|
||||
|
||||
err = r.Deregister(ctx, s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestWatch Test Watch
|
||||
func TestWatch(t *testing.T) {
|
||||
r := New([]string{"127.0.0.1:2181"}, WithRootPath("/gogf"))
|
||||
|
||||
ctx := gctx.New()
|
||||
|
||||
svc := &gsvc.LocalService{
|
||||
Name: "goframe-provider-4-tcp",
|
||||
Version: "test",
|
||||
Metadata: map[string]interface{}{"app": "goframe", gsvc.MDProtocol: "tcp"},
|
||||
Endpoints: gsvc.NewEndpoints("127.0.0.1:9000"),
|
||||
}
|
||||
t.Log("watch")
|
||||
watch, err := r.Watch(context.Background(), svc.GetPrefix())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s1, err := r.Register(context.Background(), svc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// watch svc
|
||||
// svc register, AddEvent
|
||||
next, err := watch.Proceed()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, instance := range next {
|
||||
// it will output one instance
|
||||
g.Log().Info(ctx, "Register Proceed service: ", instance)
|
||||
}
|
||||
|
||||
err = r.Deregister(context.Background(), s1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// svc deregister, DeleteEvent
|
||||
next, err = watch.Proceed()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, instance := range next {
|
||||
// it will output nothing
|
||||
g.Log().Info(ctx, "Deregister Proceed service: ", instance)
|
||||
}
|
||||
|
||||
err = watch.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = watch.Proceed()
|
||||
if err == nil {
|
||||
// if nil, stop failed
|
||||
t.Fatal()
|
||||
}
|
||||
}
|
||||
@ -308,7 +308,7 @@ func (m *Model) Value(fieldsAndWhere ...interface{}) (Value, error) {
|
||||
// Count does "SELECT COUNT(x) FROM ..." statement for the model.
|
||||
// The optional parameter `where` is the same as the parameter of Model.Where function,
|
||||
// see Model.Where.
|
||||
func (m *Model) Count(where ...interface{}) (int, error) {
|
||||
func (m *Model) Count(where ...interface{}) (int64, error) {
|
||||
var ctx = m.GetCtx()
|
||||
if len(where) > 0 {
|
||||
return m.Where(where[0], where[1:]...).Count()
|
||||
@ -324,7 +324,7 @@ func (m *Model) Count(where ...interface{}) (int, error) {
|
||||
if internalData := m.db.GetCore().GetInternalCtxDataFromCtx(ctx); internalData != nil {
|
||||
record := all[0]
|
||||
if v, ok := record[internalData.FirstResultColumn]; ok {
|
||||
return v.Int(), nil
|
||||
return v.Int64(), nil
|
||||
}
|
||||
}
|
||||
return 0, gerror.NewCode(
|
||||
@ -336,7 +336,7 @@ func (m *Model) Count(where ...interface{}) (int, error) {
|
||||
}
|
||||
|
||||
// CountColumn does "SELECT COUNT(x) FROM ..." statement for the model.
|
||||
func (m *Model) CountColumn(column string) (int, error) {
|
||||
func (m *Model) CountColumn(column string) (int64, error) {
|
||||
if len(column) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func (m *Model) getSoftFieldNameDeleted(table ...string) (field string) {
|
||||
tableName = m.tablesInit
|
||||
}
|
||||
config := m.db.GetConfig()
|
||||
if config.UpdatedAt != "" {
|
||||
if config.DeletedAt != "" {
|
||||
return m.getSoftFieldName(tableName, []string{config.DeletedAt})
|
||||
}
|
||||
return m.getSoftFieldName(tableName, deletedFiledNames)
|
||||
|
||||
92
debug/gdebug/gdebug_z_unit_test.go
Normal file
92
debug/gdebug/gdebug_z_unit_test.go
Normal file
@ -0,0 +1,92 @@
|
||||
package gdebug_test
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/debug/gdebug"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_CallerPackage(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gdebug.CallerPackage(), "github.com/gogf/gf/v2/test/gtest")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CallerFunction(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gdebug.CallerFunction(), "C")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CallerFilePath(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.CallerFilePath(), "gtest_util.go"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CallerDirectory(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.CallerDirectory(), "gtest"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CallerFileLine(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.CallerFileLine(), "gtest_util.go:36"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_CallerFileLineShort(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.CallerFileLineShort(), "gtest_util.go:36"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_FuncPath(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gdebug.FuncPath(Test_FuncPath), "github.com/gogf/gf/v2/debug/gdebug_test.Test_FuncPath")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_FuncName(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gdebug.FuncName(Test_FuncName), "gdebug_test.Test_FuncName")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PrintStack(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
gdebug.PrintStack()
|
||||
})
|
||||
}
|
||||
|
||||
func Test_GoroutineId(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertGT(gdebug.GoroutineId(), 0)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Stack(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.Stack(), "gtest_util.go:36"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_StackWithFilter(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gstr.Contains(gdebug.StackWithFilter([]string{"github.com"}), "gtest_util.go:36"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_BinVersion(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertGT(len(gdebug.BinVersion()), 0)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_BinVersionMd5(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertGT(len(gdebug.BinVersionMd5()), 0)
|
||||
})
|
||||
}
|
||||
@ -13,6 +13,13 @@ import (
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
)
|
||||
|
||||
func Test_Case(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gcode.CodeNil.String(), "-1")
|
||||
t.Assert(gcode.CodeInternalError.String(), "50:Internal Error")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Nil(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
c := gcode.New(1, "custom error", "detailed description")
|
||||
@ -21,3 +28,11 @@ func Test_Nil(t *testing.T) {
|
||||
t.Assert(c.Detail(), "detailed description")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_WithCode(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
c := gcode.WithCode(gcode.CodeInternalError, "CodeInternalError")
|
||||
t.Assert(c.Code(), gcode.CodeInternalError.Code())
|
||||
t.Assert(c.Detail(), "CodeInternalError")
|
||||
})
|
||||
}
|
||||
|
||||
@ -95,10 +95,14 @@ func Test_Wrapf(t *testing.T) {
|
||||
t.AssertNE(err, nil)
|
||||
t.Assert(err.Error(), "1")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.Wrapf(nil, ""), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_WrapSkip(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapSkip(1, nil, "2"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.WrapSkip(1, err, "2")
|
||||
err = gerror.WrapSkip(1, err, "3")
|
||||
@ -122,6 +126,7 @@ func Test_WrapSkip(t *testing.T) {
|
||||
|
||||
func Test_WrapSkipf(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapSkipf(1, nil, "2"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.WrapSkipf(1, err, "2")
|
||||
err = gerror.WrapSkipf(1, err, "3")
|
||||
@ -145,6 +150,7 @@ func Test_WrapSkipf(t *testing.T) {
|
||||
|
||||
func Test_Cause(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.Cause(nil), nil)
|
||||
err := errors.New("1")
|
||||
t.Assert(gerror.Cause(err), err)
|
||||
})
|
||||
@ -167,6 +173,17 @@ func Test_Cause(t *testing.T) {
|
||||
err = gerror.Wrap(err, "3")
|
||||
t.Assert(gerror.Cause(err), "1")
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.Stack(nil), "")
|
||||
err := errors.New("1")
|
||||
t.Assert(gerror.Stack(err), err)
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e *gerror.Error = nil
|
||||
t.Assert(e.Cause(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Format(t *testing.T) {
|
||||
@ -229,16 +246,22 @@ func Test_Stack(t *testing.T) {
|
||||
|
||||
func Test_Current(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.Current(nil), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.Wrap(err, "3")
|
||||
t.Assert(err.Error(), "3: 2: 1")
|
||||
t.Assert(gerror.Current(err).Error(), "3")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e *gerror.Error = nil
|
||||
t.Assert(e.Current(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Unwrap(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.Unwrap(nil), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.Wrap(err, "3")
|
||||
@ -253,6 +276,10 @@ func Test_Unwrap(t *testing.T) {
|
||||
err = gerror.Unwrap(err)
|
||||
t.AssertNil(err)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e *gerror.Error = nil
|
||||
t.Assert(e.Unwrap(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Code(t *testing.T) {
|
||||
@ -282,6 +309,7 @@ func Test_Code(t *testing.T) {
|
||||
t.Assert(err.Error(), "123")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapCode(gcode.New(1, "", nil), nil, "3"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.WrapCode(gcode.New(1, "", nil), err, "3")
|
||||
@ -289,6 +317,7 @@ func Test_Code(t *testing.T) {
|
||||
t.Assert(err.Error(), "3: 2: 1")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapCodef(gcode.New(1, "", nil), nil, "%s", "3"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.WrapCodef(gcode.New(1, "", nil), err, "%s", "3")
|
||||
@ -296,6 +325,7 @@ func Test_Code(t *testing.T) {
|
||||
t.Assert(err.Error(), "3: 2: 1")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapCodeSkip(gcode.New(1, "", nil), 100, nil, "3"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.WrapCodeSkip(gcode.New(1, "", nil), 100, err, "3")
|
||||
@ -303,6 +333,7 @@ func Test_Code(t *testing.T) {
|
||||
t.Assert(err.Error(), "3: 2: 1")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.WrapCodeSkipf(gcode.New(1, "", nil), 100, nil, "%s", "3"), nil)
|
||||
err := errors.New("1")
|
||||
err = gerror.Wrap(err, "2")
|
||||
err = gerror.WrapCodeSkipf(gcode.New(1, "", nil), 100, err, "%s", "3")
|
||||
@ -311,6 +342,20 @@ func Test_Code(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestError_Error(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e *gerror.Error = nil
|
||||
t.Assert(e.Error(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func TestError_Code(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e *gerror.Error = nil
|
||||
t.Assert(e.Code(), gcode.CodeNil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetCode(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
err := gerror.New("123")
|
||||
@ -321,6 +366,10 @@ func Test_SetCode(t *testing.T) {
|
||||
t.Assert(gerror.Code(err), gcode.CodeValidationFailed)
|
||||
t.Assert(err.Error(), "123")
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var err *gerror.Error = nil
|
||||
err.SetCode(gcode.CodeValidationFailed)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Json(t *testing.T) {
|
||||
@ -353,6 +402,10 @@ func Test_Equal(t *testing.T) {
|
||||
t.Assert(gerror.Equal(err3, err4), false)
|
||||
t.Assert(gerror.Equal(err1, err4), false)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var e = new(gerror.Error)
|
||||
t.Assert(e.Equal(e), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Is(t *testing.T) {
|
||||
@ -375,6 +428,7 @@ func Test_HashError(t *testing.T) {
|
||||
|
||||
func Test_HashCode(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gerror.HasCode(nil, gcode.CodeNotAuthorized), false)
|
||||
err1 := errors.New("1")
|
||||
err2 := gerror.WrapCode(gcode.CodeNotAuthorized, err1, "2")
|
||||
err3 := gerror.Wrap(err2, "3")
|
||||
@ -385,3 +439,14 @@ func Test_HashCode(t *testing.T) {
|
||||
t.Assert(gerror.HasCode(err4, gcode.CodeNotAuthorized), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_NewOption(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(gerror.NewOption(gerror.Option{
|
||||
Error: errors.New("NewOptionError"),
|
||||
Stack: true,
|
||||
Text: "Text",
|
||||
Code: gcode.CodeNotAuthorized,
|
||||
}), gerror.New("NewOptionError"))
|
||||
})
|
||||
}
|
||||
|
||||
102
frame/g/g_z_unit_test.go
Normal file
102
frame/g/g_z_unit_test.go
Normal file
@ -0,0 +1,102 @@
|
||||
package g_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
)
|
||||
|
||||
func Test_NewVar(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(g.NewVar(1).Int(), 1)
|
||||
t.Assert(g.NewVar(1, true).Int(), 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Dump(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.Dump("GoFrame")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_DumpTo(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.DumpTo(os.Stdout, "GoFrame", gutil.DumpOption{})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_DumpWithType(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.DumpWithType("GoFrame", 123)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_DumpWithOption(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.DumpWithOption("GoFrame", gutil.DumpOption{})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Try(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.Try(ctx, func(ctx context.Context) {
|
||||
g.Dump("GoFrame")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_TryCatch(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.TryCatch(ctx, func(ctx context.Context) {
|
||||
g.Dump("GoFrame")
|
||||
}, func(ctx context.Context, exception error) {
|
||||
g.Dump(exception)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_IsNil(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(g.IsNil(nil), true)
|
||||
t.Assert(g.IsNil(0), false)
|
||||
t.Assert(g.IsNil("GoFrame"), false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_IsEmpty(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(g.IsEmpty(nil), true)
|
||||
t.Assert(g.IsEmpty(0), true)
|
||||
t.Assert(g.IsEmpty("GoFrame"), false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetDebug(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
g.SetDebug(true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Object(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(g.Client(), nil)
|
||||
t.AssertNE(g.Server(), nil)
|
||||
t.AssertNE(g.TCPServer(), nil)
|
||||
t.AssertNE(g.UDPServer(), nil)
|
||||
t.AssertNE(g.View(), nil)
|
||||
t.AssertNE(g.Config(), nil)
|
||||
t.AssertNE(g.Cfg(), nil)
|
||||
t.AssertNE(g.Resource(), nil)
|
||||
t.AssertNE(g.I18n(), nil)
|
||||
t.AssertNE(g.Res(), nil)
|
||||
t.AssertNE(g.Log(), nil)
|
||||
t.AssertNE(g.Validator(), nil)
|
||||
})
|
||||
}
|
||||
@ -427,14 +427,17 @@ func (c *AdapterMemory) syncEventAndClearExpired(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
// Processing expired keys from LRU.
|
||||
if c.cap > 0 && c.lruGetList.Len() > 0 {
|
||||
for {
|
||||
if v := c.lruGetList.PopFront(); v != nil {
|
||||
c.lru.Push(v)
|
||||
} else {
|
||||
break
|
||||
if c.cap > 0 {
|
||||
if c.lruGetList.Len() > 0 {
|
||||
for {
|
||||
if v := c.lruGetList.PopFront(); v != nil {
|
||||
c.lru.Push(v)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
c.lru.SyncAndClear(ctx)
|
||||
}
|
||||
// ========================
|
||||
// Data Cleaning up.
|
||||
|
||||
@ -8,7 +8,6 @@ package gcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/container/glist"
|
||||
"github.com/gogf/gf/v2/container/gmap"
|
||||
@ -35,7 +34,6 @@ func newMemCacheLru(cache *AdapterMemory) *adapterMemoryLru {
|
||||
rawList: glist.New(true),
|
||||
closed: gtype.NewBool(),
|
||||
}
|
||||
gtimer.AddSingleton(context.Background(), time.Second, lru.SyncAndClear)
|
||||
return lru
|
||||
}
|
||||
|
||||
|
||||
@ -50,34 +50,35 @@ func CopyFile(src, dst string) (err error) {
|
||||
if src == dst {
|
||||
return nil
|
||||
}
|
||||
in, err := Open(src)
|
||||
var inFile *os.File
|
||||
inFile, err = Open(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if e := in.Close(); e != nil {
|
||||
if e := inFile.Close(); e != nil {
|
||||
err = gerror.Wrapf(e, `file close failed for "%s"`, src)
|
||||
}
|
||||
}()
|
||||
out, err := Create(dst)
|
||||
var outFile *os.File
|
||||
outFile, err = Create(dst)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if e := out.Close(); e != nil {
|
||||
if e := outFile.Close(); e != nil {
|
||||
err = gerror.Wrapf(e, `file close failed for "%s"`, dst)
|
||||
}
|
||||
}()
|
||||
if _, err = io.Copy(out, in); err != nil {
|
||||
if _, err = io.Copy(outFile, inFile); err != nil {
|
||||
err = gerror.Wrapf(err, `io.Copy failed from "%s" to "%s"`, src, dst)
|
||||
return
|
||||
}
|
||||
if err = out.Sync(); err != nil {
|
||||
if err = outFile.Sync(); err != nil {
|
||||
err = gerror.Wrapf(err, `file sync failed for file "%s"`, dst)
|
||||
return
|
||||
}
|
||||
err = Chmod(dst, DefaultPermCopy)
|
||||
if err != nil {
|
||||
if err = Chmod(dst, DefaultPermCopy); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
@ -9,6 +9,7 @@ package glog_test
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@ -20,6 +21,386 @@ import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
func TestCase(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(glog.Instance(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDefaultLogger(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(defaultLog, nil)
|
||||
log := glog.New()
|
||||
glog.SetDefaultLogger(log)
|
||||
t.AssertEQ(glog.DefaultLogger(), defaultLog)
|
||||
t.AssertEQ(glog.Expose(), defaultLog)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAPI(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.Print(ctx, "Print")
|
||||
glog.Printf(ctx, "%s", "Printf")
|
||||
glog.Info(ctx, "Info")
|
||||
glog.Infof(ctx, "%s", "Infof")
|
||||
glog.Debug(ctx, "Debug")
|
||||
glog.Debugf(ctx, "%s", "Debugf")
|
||||
glog.Notice(ctx, "Notice")
|
||||
glog.Noticef(ctx, "%s", "Noticef")
|
||||
glog.Warning(ctx, "Warning")
|
||||
glog.Warningf(ctx, "%s", "Warningf")
|
||||
glog.Error(ctx, "Error")
|
||||
glog.Errorf(ctx, "%s", "Errorf")
|
||||
glog.Critical(ctx, "Critical")
|
||||
glog.Criticalf(ctx, "%s", "Criticalf")
|
||||
})
|
||||
}
|
||||
|
||||
func TestChaining(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(glog.Cat("module"), nil)
|
||||
t.AssertNE(glog.File("test.log"), nil)
|
||||
t.AssertNE(glog.Level(glog.LEVEL_ALL), nil)
|
||||
t.AssertNE(glog.LevelStr("all"), nil)
|
||||
t.AssertNE(glog.Skip(1), nil)
|
||||
t.AssertNE(glog.Stack(false), nil)
|
||||
t.AssertNE(glog.StackWithFilter("none"), nil)
|
||||
t.AssertNE(glog.Stdout(false), nil)
|
||||
t.AssertNE(glog.Header(false), nil)
|
||||
t.AssertNE(glog.Line(false), nil)
|
||||
t.AssertNE(glog.Async(false), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetFile(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetFile("test.log")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetLevel(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetLevel(glog.LEVEL_ALL)
|
||||
t.Assert(glog.GetLevel()&glog.LEVEL_ALL, glog.LEVEL_ALL)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetAsync(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetAsync(false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetStdoutPrint(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetStdoutPrint(false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetHeaderPrint(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetHeaderPrint(false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetPrefix(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetPrefix("log_prefix")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetConfigWithMap(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(glog.SetConfigWithMap(map[string]interface{}{
|
||||
"level": "all",
|
||||
}), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetPath(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(glog.SetPath("/var/log"), nil)
|
||||
t.Assert(glog.GetPath(), "/var/log")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetWriter(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetWriter(os.Stdout)
|
||||
t.Assert(glog.GetWriter(), os.Stdout)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetFlags(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetFlags(glog.F_ASYNC)
|
||||
t.Assert(glog.GetFlags(), glog.F_ASYNC)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetCtxKeys(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetCtxKeys("SpanId", "TraceId")
|
||||
t.Assert(glog.GetCtxKeys(), []string{"SpanId", "TraceId"})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PrintStack(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.PrintStack(ctx, 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetStack(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetStack(true)
|
||||
t.Assert(glog.GetStack(1), "")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetLevelStr(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(glog.SetLevelStr("all"), nil)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
t.AssertNE(l.SetLevelStr("test"), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetLevelPrefix(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetLevelPrefix(glog.LEVEL_ALL, "LevelPrefix")
|
||||
t.Assert(glog.GetLevelPrefix(glog.LEVEL_ALL), "LevelPrefix")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetLevelPrefixes(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetLevelPrefixes(map[int]string{
|
||||
glog.LEVEL_ALL: "ALL_Prefix",
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetHandlers(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetHandlers(func(ctx context.Context, in *glog.HandlerInput) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetWriterColorEnable(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
glog.SetWriterColorEnable(true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Instance(t *testing.T) {
|
||||
defaultLog := glog.DefaultLogger().Clone()
|
||||
defer glog.SetDefaultLogger(defaultLog)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertNE(glog.Instance("gf"), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_GetConfig(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
config := glog.DefaultLogger().GetConfig()
|
||||
t.Assert(config.Path, "")
|
||||
t.Assert(config.StdoutPrint, true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Write(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
len, err := l.Write([]byte("GoFrame"))
|
||||
t.AssertNil(err)
|
||||
t.Assert(len, 7)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_To(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.DefaultLogger().Clone()
|
||||
logTo := l.To(os.Stdout)
|
||||
t.AssertNE(logTo, nil)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logTo := l.To(os.Stdout)
|
||||
t.AssertNE(logTo, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Path(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.DefaultLogger().Clone()
|
||||
logPath := l.Path("./")
|
||||
t.AssertNE(logPath, nil)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logPath := l.Path("./")
|
||||
t.AssertNE(logPath, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Cat(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logCat := l.Cat(".gf")
|
||||
t.AssertNE(logCat, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Level(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logLevel := l.Level(glog.LEVEL_ALL)
|
||||
t.AssertNE(logLevel, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_LevelStr(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logLevelStr := l.LevelStr("all")
|
||||
t.AssertNE(logLevelStr, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Skip(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logSkip := l.Skip(1)
|
||||
t.AssertNE(logSkip, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Stack(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logStack := l.Stack(true)
|
||||
t.AssertNE(logStack, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_StackWithFilter(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logStackWithFilter := l.StackWithFilter("gtest")
|
||||
t.AssertNE(logStackWithFilter, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Stdout(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logStdout := l.Stdout(true)
|
||||
t.AssertNE(logStdout, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Header(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logHeader := l.Header(true)
|
||||
t.AssertNE(logHeader, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Line(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logLine := l.Line(true)
|
||||
t.AssertNE(logLine, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Chaining_Async(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
logAsync := l.Async(true)
|
||||
t.AssertNE(logAsync, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Config_SetDebug(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
l.SetDebug(false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Config_AppendCtxKeys(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
l.AppendCtxKeys("Trace-Id", "Span-Id", "Test")
|
||||
l.AppendCtxKeys("Trace-Id-New", "Span-Id-New", "Test")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Config_SetPath(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
t.AssertNE(l.SetPath(""), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Config_SetStdoutColorDisabled(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
l.SetStdoutColorDisabled(false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Ctx(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
w := bytes.NewBuffer(nil)
|
||||
@ -42,8 +423,13 @@ func Test_Ctx_Config(t *testing.T) {
|
||||
m := map[string]interface{}{
|
||||
"CtxKeys": g.SliceStr{"Trace-Id", "Span-Id", "Test"},
|
||||
}
|
||||
var nilMap map[string]interface{}
|
||||
|
||||
err := l.SetConfigWithMap(m)
|
||||
t.AssertNil(err)
|
||||
err = l.SetConfigWithMap(nilMap)
|
||||
t.AssertNE(err, nil)
|
||||
|
||||
ctx := context.WithValue(context.Background(), "Trace-Id", "1234567890")
|
||||
ctx = context.WithValue(ctx, "Span-Id", "abcdefg")
|
||||
|
||||
|
||||
@ -92,6 +92,15 @@ func Test_Format(t *testing.T) {
|
||||
}
|
||||
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var ti *gtime.Time = nil
|
||||
t.Assert(ti.Format("Y-m-d h:i:s"), "")
|
||||
t.Assert(ti.FormatNew("Y-m-d h:i:s"), nil)
|
||||
t.Assert(ti.FormatTo("Y-m-d h:i:s"), nil)
|
||||
t.Assert(ti.Layout("Y-m-d h:i:s"), "")
|
||||
t.Assert(ti.LayoutNew("Y-m-d h:i:s"), nil)
|
||||
t.Assert(ti.LayoutTo("Y-m-d h:i:s"), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Format_ZeroString(t *testing.T) {
|
||||
|
||||
@ -18,10 +18,19 @@ import (
|
||||
func Test_SetTimeZone(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gtime.SetTimeZone("Asia/Shanghai"), nil)
|
||||
t.AssertNE(gtime.SetTimeZone("testzone"), nil)
|
||||
// t.Assert(time.Local.String(), "Asia/Shanghai")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_TimestampStr(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertGT(len(gtime.TimestampMilliStr()), 0)
|
||||
t.AssertGT(len(gtime.TimestampMicroStr()), 0)
|
||||
t.AssertGT(len(gtime.TimestampNanoStr()), 0)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Nanosecond(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
nanos := gtime.TimestampNano()
|
||||
@ -69,6 +78,14 @@ func Test_Datetime(t *testing.T) {
|
||||
}
|
||||
t.Assert(datetime, timeTemp.Time.Format("2006-01-02 15:04:05"))
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeTemp, err := gtime.StrToTime("")
|
||||
t.Assert(err, nil)
|
||||
t.AssertLT(timeTemp.Unix(), 0)
|
||||
timeTemp, err = gtime.StrToTime("2006-01")
|
||||
t.AssertNE(err, nil)
|
||||
t.Assert(timeTemp, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_ISO8601(t *testing.T) {
|
||||
|
||||
@ -8,6 +8,7 @@ package gtime_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/internal/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -48,6 +49,27 @@ func Test_New(t *testing.T) {
|
||||
timeTemp := gtime.New("2021-2-9 08:01:21")
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2021-02-09 08:01:21")
|
||||
t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2021-02-09 08:01:21")
|
||||
|
||||
timeTemp = gtime.New("2021-02-09 08:01:21", []byte("Y-m-d H:i:s"))
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2021-02-09 08:01:21")
|
||||
t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2021-02-09 08:01:21")
|
||||
|
||||
timeTemp = gtime.New([]byte("2021-02-09 08:01:21"))
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2021-02-09 08:01:21")
|
||||
t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2021-02-09 08:01:21")
|
||||
|
||||
timeTemp = gtime.New([]byte("2021-02-09 08:01:21"), "Y-m-d H:i:s")
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2021-02-09 08:01:21")
|
||||
t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2021-02-09 08:01:21")
|
||||
|
||||
timeTemp = gtime.New([]byte("2021-02-09 08:01:21"), []byte("Y-m-d H:i:s"))
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2021-02-09 08:01:21")
|
||||
t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2021-02-09 08:01:21")
|
||||
})
|
||||
//
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.Assert(gtime.New(gtime.Time{}), nil)
|
||||
t.Assert(gtime.New(>ime.Time{}), nil)
|
||||
})
|
||||
}
|
||||
|
||||
@ -124,6 +146,8 @@ func Test_NewFromTimeStamp(t *testing.T) {
|
||||
t.Assert(timeTemp.Format("Y-m-d H:i:s"), "2019-04-05 18:24:06")
|
||||
timeTemp1 := gtime.NewFromTimeStamp(0)
|
||||
t.Assert(timeTemp1.Format("Y-m-d H:i:s"), "0001-01-01 00:00:00")
|
||||
timeTemp2 := gtime.NewFromTimeStamp(155445984)
|
||||
t.Assert(timeTemp2.Format("Y-m-d H:i:s"), "1974-12-05 11:26:24")
|
||||
})
|
||||
}
|
||||
|
||||
@ -134,6 +158,50 @@ func Test_Time_Second(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_IsZero(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var ti *gtime.Time = nil
|
||||
t.Assert(ti.IsZero(), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_AddStr(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
gt := gtime.New("2018-08-08 08:08:08")
|
||||
gt1, err := gt.AddStr("10T")
|
||||
t.Assert(gt1, nil)
|
||||
t.AssertNE(err, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_Equal(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var t1 *gtime.Time = nil
|
||||
var t2 = gtime.New()
|
||||
t.Assert(t1.Equal(t2), false)
|
||||
t.Assert(t1.Equal(t1), true)
|
||||
t.Assert(t2.Equal(t1), false)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_After(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var t1 *gtime.Time = nil
|
||||
var t2 = gtime.New()
|
||||
t.Assert(t1.After(t2), false)
|
||||
t.Assert(t2.After(t1), true)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_Sub(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var t1 *gtime.Time = nil
|
||||
var t2 = gtime.New()
|
||||
t.Assert(t1.Sub(t2), time.Duration(0))
|
||||
t.Assert(t2.Sub(t1), time.Duration(0))
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Time_Nanosecond(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeTemp := gtime.Now()
|
||||
@ -468,4 +536,15 @@ func Test_DeepCopy(t *testing.T) {
|
||||
u2 := gutil.Copy(u1).(*User)
|
||||
t.Assert(u1, u2)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var t1 *gtime.Time = nil
|
||||
t.Assert(t1.DeepCopy(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_UnmarshalJSON(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var t1 gtime.Time
|
||||
t.AssertNE(json.Unmarshal([]byte("{}"), &t1), nil)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2,5 +2,5 @@ package gf
|
||||
|
||||
const (
|
||||
// VERSION is the current GoFrame version.
|
||||
VERSION = "v2.2.4"
|
||||
VERSION = "v2.2.5"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user