mirror of
https://gitee.com/johng/gf
synced 2026-06-09 02:57:43 +08:00
Compare commits
182 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02e467fb57 | |||
| ec994f3080 | |||
| 1181ab499c | |||
| 5424935fd9 | |||
| b9fbfb91bd | |||
| 62f66b4fec | |||
| eef9da9a41 | |||
| 7d32be3b6c | |||
| c2ad9f5fb9 | |||
| 4847fecdaa | |||
| f75383e0c5 | |||
| f683dccb6f | |||
| 6fb106b618 | |||
| 97956ad903 | |||
| 5d72a5b5ae | |||
| 1d7ded562c | |||
| 0d87b601cc | |||
| 33fbedffb8 | |||
| 2cfcbc82e1 | |||
| e1721cb1b6 | |||
| 1d264a6545 | |||
| 565e48f6f1 | |||
| 2b20c77bc0 | |||
| 1665d92136 | |||
| f128cb9f61 | |||
| 6d55b30b39 | |||
| 953ea55899 | |||
| 966c93af00 | |||
| 41a0b52939 | |||
| 8281d9cdd1 | |||
| b0ece3bd8f | |||
| 19a856549a | |||
| 65bd31bb65 | |||
| a3830f0820 | |||
| 5f8656eb41 | |||
| 141bee9c49 | |||
| aa44c0fb11 | |||
| 79e2d30849 | |||
| e8a9c7ac72 | |||
| 006054d13a | |||
| b39d653fe9 | |||
| d9e7d4249f | |||
| 34ad4ae166 | |||
| 69684f5023 | |||
| 2ed1854f0c | |||
| 09da0f7388 | |||
| 7f943c6b5f | |||
| ed3fc529ed | |||
| 2eb0511ef5 | |||
| 8bc1f457c7 | |||
| 77a727e1d7 | |||
| 16cc3c0fca | |||
| 96106ace92 | |||
| 13e528abb6 | |||
| 0d5dfe59b9 | |||
| 8fd88307f7 | |||
| 57244a9553 | |||
| fb8aac38dd | |||
| 8f953dabe5 | |||
| d63c2882fd | |||
| 952eb7df15 | |||
| dfc76ddb76 | |||
| b0cddc29e4 | |||
| dfc61cb273 | |||
| 05922e4f21 | |||
| 6cf4bf81e5 | |||
| ad43989944 | |||
| 31e7037e3e | |||
| 425d45e502 | |||
| 9ddb148fcb | |||
| e4d34abd7e | |||
| 16103c43eb | |||
| 7fad4b686c | |||
| cd00ac446b | |||
| e2906fba0b | |||
| acd5e72f6c | |||
| 8f1fd259d4 | |||
| d9041da426 | |||
| 269ddb04af | |||
| b1c2b9f4e0 | |||
| 7e9fe8ea98 | |||
| af81bf2bde | |||
| 55addaa8ea | |||
| 6ccc4d119f | |||
| c05a91cdc9 | |||
| 077d8b9f48 | |||
| 15a6680833 | |||
| 6c61704e60 | |||
| cfa0b99cd8 | |||
| c0bb8bef06 | |||
| 86f9d5c39d | |||
| 33f2ae5fc4 | |||
| ea1277d76c | |||
| ee89a06b3e | |||
| a31108e753 | |||
| 2bf9bc98a7 | |||
| d67975249c | |||
| d3a2bef9ba | |||
| b7f67e3162 | |||
| 1a20edc0b0 | |||
| f80ba1473e | |||
| 89a8203949 | |||
| fd6321e71b | |||
| 7dffd9d1ff | |||
| 51a156420d | |||
| c92323c681 | |||
| 10e03eef3b | |||
| e151055521 | |||
| 1f8408b622 | |||
| 98ddadb131 | |||
| a5ac12545a | |||
| e58384d815 | |||
| ab381dacfe | |||
| 9162fde14a | |||
| 6cf1714a07 | |||
| c402e17605 | |||
| 25746e9844 | |||
| a8a8dbeab8 | |||
| 6113df2b3e | |||
| 8f7363df41 | |||
| dafc79bf80 | |||
| 9ae537cafc | |||
| 162df6b250 | |||
| 12f28dfc95 | |||
| 5d7d8abbde | |||
| b960faec45 | |||
| 9a057b757d | |||
| 296c4b750b | |||
| 7ecc47e127 | |||
| d03180ff4d | |||
| c1c52b072e | |||
| 72be3803ec | |||
| 5cb4a8557d | |||
| 7787135549 | |||
| 56368500a3 | |||
| 846c6a579e | |||
| 573179060e | |||
| fda345577a | |||
| 8387710473 | |||
| 3af3fd1428 | |||
| c7c6e2866e | |||
| 7172ae0232 | |||
| 4eac97a7d8 | |||
| 352e4c088a | |||
| 4d5814fc43 | |||
| 6d13b91d37 | |||
| 0376c99b5a | |||
| 77d9e472b7 | |||
| 2911ebb5d7 | |||
| f4d01f56c6 | |||
| 878305fee3 | |||
| 0460a53f53 | |||
| e622f6aff2 | |||
| 9e96a30ea2 | |||
| d188fbdf5a | |||
| 06c16bf560 | |||
| 29ea9e3237 | |||
| b01add2925 | |||
| a98ad9577b | |||
| ef8351151d | |||
| f6bb3c848e | |||
| 3fd4cbbbfd | |||
| b102e0dbc5 | |||
| 1c0e8f77c8 | |||
| bebcb70b14 | |||
| 165602ae0a | |||
| 216a928861 | |||
| a157c3f940 | |||
| 5a23459b23 | |||
| 538b282f43 | |||
| 86f51f1e4a | |||
| 622f76d5fb | |||
| 65e06b12ae | |||
| b714f7db69 | |||
| 1063922682 | |||
| 2c6168129a | |||
| 575349929b | |||
| 3913a89434 | |||
| 1bc8c9e3e2 | |||
| b4a0cca9c4 | |||
| 78b13ef4e1 | |||
| a49df101cd |
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/garray"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/garray"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/garray"
|
||||
"github.com/gogf/gf/container/garray"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/garray"
|
||||
"github.com/gogf/gf/container/garray"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/garray"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,13 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gmap"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建一个默认的gmap对象,
|
||||
// 默认情况下该gmap对象支持并发安全特性,
|
||||
// 初始化时可以给定false参数关闭并发安全特性,当做一个普通的map使用。
|
||||
// 默认情况下该gmap对象不支持并发安全特性,
|
||||
// 初始化时可以给定true参数关闭并发安全特性,当做一个普通的map使用。
|
||||
m := gmap.New()
|
||||
|
||||
// 设置键值对
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g/container/gmap"
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/gmap"
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/gmap"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gmap"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gpool"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gpool"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,10 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gpool"
|
||||
"github.com/gogf/gf/g/net/gtcp"
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gpool"
|
||||
"github.com/gogf/gf/net/gtcp"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,10 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gqueue"
|
||||
"github.com/gogf/gf/g/os/gtime"
|
||||
"github.com/gogf/gf/g/os/gtimer"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gqueue"
|
||||
"github.com/gogf/gf/g/os/gtimer"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,10 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gqueue"
|
||||
"github.com/gogf/gf/g/os/gtime"
|
||||
"github.com/gogf/gf/g/os/gtimer"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gring"
|
||||
|
||||
"github.com/gogf/gf/container/gring"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gring"
|
||||
|
||||
"github.com/gogf/gf/container/gring"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gset"
|
||||
|
||||
"github.com/gogf/gf/container/gset"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/container/gset"
|
||||
|
||||
"github.com/gogf/gf/container/gset"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gtree"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gtree"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gtree"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g/container/gtree"
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/container/gtype"
|
||||
|
||||
"github.com/gogf/gf/container/gtype"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
//_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mssql数据库操作示例,不作为单元测试使用
|
||||
@ -27,7 +27,7 @@ func init() {
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/geg/frame")
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/frame")
|
||||
//db = g.Database()
|
||||
|
||||
//gdb.SetConfig(gdb.ConfigNode {
|
||||
5
.example/database/gdb/mysql/config.toml
Normal file
5
.example/database/gdb/mysql/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
# MySQL数据库配置
|
||||
[database]
|
||||
link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
|
||||
|
||||
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mysql数据库操作示例,不作为单元测试使用
|
||||
@ -26,7 +26,7 @@ func init() {
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/geg/frame")
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/frame")
|
||||
//db = g.Database()
|
||||
|
||||
//gdb.SetConfig(gdb.ConfigNode {
|
||||
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/crypto/gaes"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
|
||||
"github.com/gogf/gf/crypto/gaes"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/os/gtime"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
50
.example/database/gdb/mysql/gdb_issue_278.go
Normal file
50
.example/database/gdb/mysql/gdb_issue_278.go
Normal file
@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
var (
|
||||
tableName = "orders"
|
||||
dao = g.DB().Table(tableName).Safe()
|
||||
)
|
||||
|
||||
type OrderServiceEntity struct {
|
||||
GoodsPrice float64 `json:"goods_price" gvalid:"required"`
|
||||
PayTo int8 `json:"payTo" gvalid:"required"`
|
||||
PayStatus int8 `json:"payStatus" `
|
||||
CreateTime string `json:"createTime" `
|
||||
AppId string `json:"appId" gvalid:"required"`
|
||||
PayUser string `json:"pay_user" gvalid:"required"`
|
||||
QrUrl string `json:"qr_url" `
|
||||
}
|
||||
|
||||
type Create struct {
|
||||
Id int64 `json:"id" gconv:"id"`
|
||||
GoodsPrice float64 `json:"goodsPrice" gconv:"goods_price"`
|
||||
PayTo int8 `json:"payTo" gconv:"pay_to"`
|
||||
PayStatus int8 `json:"payStatus" gconv:"pay_status"`
|
||||
CreateTime string `json:"createTime" gconv:"create_time"`
|
||||
UserId int `json:"user_id" `
|
||||
PayUser string `json:"pay_user" `
|
||||
QrUrl string `json:"qr_url" `
|
||||
}
|
||||
|
||||
func main() {
|
||||
g.DB().SetDebug(true)
|
||||
userInfo := Create{
|
||||
Id: 3,
|
||||
}
|
||||
orderService := OrderServiceEntity{
|
||||
GoodsPrice: 0.1,
|
||||
PayTo: 1,
|
||||
}
|
||||
size, err := dao.Where("user_id", userInfo.Id).
|
||||
And("goods_price", float64(100.10)).
|
||||
And("pay_status", 0).
|
||||
And("pay_to", orderService.PayTo).Count()
|
||||
fmt.Println(err)
|
||||
fmt.Println(size)
|
||||
}
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/g/encoding/gparser"
|
||||
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -1,8 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
18
.example/database/gdb/mysql/gdb_tables.go
Normal file
18
.example/database/gdb/mysql/gdb_tables.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
|
||||
tables, err := db.Tables()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if tables != nil {
|
||||
g.Dump(tables)
|
||||
}
|
||||
}
|
||||
25
.example/database/gdb/mysql/gdb_tables_fields.go
Normal file
25
.example/database/gdb/mysql/gdb_tables_fields.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
|
||||
tables, e := db.Tables()
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if tables != nil {
|
||||
g.Dump(tables)
|
||||
for _, table := range tables {
|
||||
fields, err := db.TableFields(table)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
g.Dump(fields)
|
||||
}
|
||||
}
|
||||
}
|
||||
34
.example/database/gdb/mysql/gdb_update_field.go
Normal file
34
.example/database/gdb/mysql/gdb_update_field.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
table := "medicine_clinics_upload_yinchuan"
|
||||
list, err := db.Table(table).All()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
panic(err)
|
||||
}
|
||||
content := ""
|
||||
for _, item := range list {
|
||||
if j, err := gjson.DecodeToJson(item["upload_data"].String()); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
s, _ := j.ToJsonIndentString()
|
||||
content += item["id"].String() + "\t" + item["medicine_clinic_id"].String() + "\t"
|
||||
content += s
|
||||
content += "\n\n"
|
||||
//if _, err := db.Table(table).Data("data_decode", s).Where("id", item["id"].Int()).Update(); err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
}
|
||||
}
|
||||
gfile.PutContents("/Users/john/Temp/medicine_clinics_upload_yinchuan.txt", content)
|
||||
}
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -3,12 +3,11 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
r, e := db.Table("test").Where("id IN (?)", []interface{}{1, 2}).All()
|
||||
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
//_ "github.com/mattn/go-oci8"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mysql数据库操作示例,不作为单元测试使用
|
||||
@ -26,7 +26,7 @@ func init() {
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/geg/frame")
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/frame")
|
||||
//db = g.Database()
|
||||
|
||||
//gdb.SetConfig(gdb.ConfigNode {
|
||||
@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
//import (
|
||||
// _ "github.com/gogf/gf/third/github.com/mattn/go-sqlite3"
|
||||
// "github.com/gogf/gf/g/database/gdb"
|
||||
// "github.com/gogf/gf/g"
|
||||
// _ "github.com/mattn/go-sqlite3"
|
||||
// "github.com/gogf/gf/database/gdb"
|
||||
// "github.com/gogf/gf/frame/g"
|
||||
// "fmt"
|
||||
//)
|
||||
//
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/database/gredis"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/database/gredis"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
// 使用原生gredis.New操作redis,但是注意需要自己调用Close方法关闭redis链接池
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
// 使用框架封装的g.Redis()方法获得redis操作对象单例,不需要开发者显示调用Close方法
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
60
.example/database/gredis/migration/migration.go
Normal file
60
.example/database/gredis/migration/migration.go
Normal file
@ -0,0 +1,60 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/os/gcmd"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
"github.com/gogf/gf/database/gredis"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
batchNumber := 1000
|
||||
redis1Config, err := gredis.ConfigFromStr("im-redis-slave:6379,9")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
redis2Config, err := gredis.ConfigFromStr("r-bp1f0a5d4efd8744.redis.rds.aliyuncs.com:6379,9")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gredis.SetConfig(redis1Config)
|
||||
|
||||
v, err := g.Redis().DoVar("keys", "*")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
array := garray.NewStrArrayFrom(v.Strings())
|
||||
for {
|
||||
slice := array.PopLefts(batchNumber)
|
||||
if len(slice) > 0 {
|
||||
// `migrate %s %d "" 0 2000 copy replace auth %s keys %s`,
|
||||
params := g.Slice{
|
||||
redis2Config.Host,
|
||||
redis2Config.Port,
|
||||
"",
|
||||
redis2Config.Db,
|
||||
2000,
|
||||
"copy",
|
||||
"replace",
|
||||
"keys",
|
||||
}
|
||||
params = append(params, gconv.Interfaces(slice)...)
|
||||
fmt.Println(params)
|
||||
if gcmd.GetOpt("dryrun") == "0" {
|
||||
if v, err := g.Redis().DoVar("migrate", params...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
fmt.Println(v.String())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
fmt.Println("done")
|
||||
}
|
||||
11
.example/debug/gdebug/gdebug.go
Normal file
11
.example/debug/gdebug/gdebug.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/debug/gdebug"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(gdebug.CallerPackage())
|
||||
fmt.Println(gdebug.CallerFunction())
|
||||
}
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gbase64"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbase64"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gbinary"
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gbinary"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gbinary"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gcharset"
|
||||
|
||||
"github.com/gogf/gf/encoding/gcharset"
|
||||
)
|
||||
|
||||
func main() {
|
||||
15
.example/encoding/gcompress/unzip.go
Normal file
15
.example/encoding/gcompress/unzip.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gcompress"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := gcompress.UnZipFile(
|
||||
`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg\encoding\gcompress\data.zip`,
|
||||
`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg`,
|
||||
)
|
||||
fmt.Println(err)
|
||||
}
|
||||
16
.example/encoding/gcompress/unzip_content.go
Normal file
16
.example/encoding/gcompress/unzip_content.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gcompress"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := gcompress.UnZipContent(
|
||||
gfile.GetBytes(`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg\encoding\gcompress\data.zip`),
|
||||
`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg`,
|
||||
)
|
||||
fmt.Println(err)
|
||||
}
|
||||
16
.example/encoding/gcompress/zip.go
Normal file
16
.example/encoding/gcompress/zip.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gcompress"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := gcompress.ZipPath(
|
||||
`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg`,
|
||||
`D:\Workspace\Go\GOPATH\src\github.com\gogf\gf\geg\encoding\gcompress\data.zip`,
|
||||
"my-dir",
|
||||
)
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/ghash"
|
||||
"strconv"
|
||||
|
||||
"github.com/gogf/gf/encoding/ghash"
|
||||
)
|
||||
|
||||
func main() {
|
||||
16
.example/encoding/gini/gini.go
Normal file
16
.example/encoding/gini/gini.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/encoding/gini"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := `
|
||||
a = b
|
||||
|
||||
`
|
||||
m, err := gini.Decode([]byte(s))
|
||||
fmt.Println(err)
|
||||
fmt.Println(m)
|
||||
}
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gjson"
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
"github.com/gogf/gf/g/os/gtime"
|
||||
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
)
|
||||
|
||||
func getByPattern() {
|
||||
156
.example/encoding/gjson/issue#IZXU2.go
Normal file
156
.example/encoding/gjson/issue#IZXU2.go
Normal file
@ -0,0 +1,156 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
)
|
||||
|
||||
type XinYanModel struct {
|
||||
Success bool `json:"success"`
|
||||
Data Data `json:"data"`
|
||||
ErrorCode interface{} `json:"errorCode"`
|
||||
ErrorMsg interface{} `json:"errorMsg"`
|
||||
}
|
||||
type ApplyReportDetail struct {
|
||||
ApplyScore string `json:"apply_score"`
|
||||
ApplyCredibility string `json:"apply_credibility"`
|
||||
QueryOrgCount string `json:"apply_query_org_count"`
|
||||
QueryFinanceCount string `json:"apply_query_finance_count"`
|
||||
QueryCashCount string `json:"apply_query_cash_count"`
|
||||
QuerySumCount string `json:"apply_query_sum_count"`
|
||||
LatestQueryTime string `json:"apply_latest_query_time"`
|
||||
LatestOneMonth string `json:"apply_latest_one_month"`
|
||||
LatestThreeMonth string `json:"apply_latest_three_month"`
|
||||
LatestSixMonth string `json:"apply_latest_six_month"`
|
||||
}
|
||||
type BehaviorReportDetail struct {
|
||||
LoansScore string `json:"behavior_report_detailloans_score"`
|
||||
LoansCredibility string `json:"behavior_report_detailloans_credibility"`
|
||||
LoansCount string `json:"behavior_report_detailloans_count"`
|
||||
LoansSettleCount string `json:"behavior_report_detailloans_settle_count"`
|
||||
LoansOverdueCount string `json:"behavior_report_detailloans_overdue_count"`
|
||||
LoansOrgCount string `json:"behavior_report_detailloans_org_count"`
|
||||
ConsfinOrgCount string `json:"behavior_report_detailconsfin_org_count"`
|
||||
LoansCashCount string `json:"behavior_report_detailloans_cash_count"`
|
||||
LatestOneMonth string `json:"behavior_report_detaillatest_one_month"`
|
||||
LatestThreeMonth string `json:"behavior_report_detaillatest_three_month"`
|
||||
LatestSixMonth string `json:"behavior_report_detaillatest_six_month"`
|
||||
HistorySucFee string `json:"behavior_report_detailhistory_suc_fee"`
|
||||
HistoryFailFee string `json:"behavior_report_detailhistory_fail_fee"`
|
||||
LatestOneMonthSuc string `json:"behavior_report_detaillatest_one_month_suc"`
|
||||
LatestOneMonthFail string `json:"behavior_report_detaillatest_one_month_fail"`
|
||||
LoansLongTime string `json:"behavior_report_detailloans_long_time"`
|
||||
LoansLatestTime string `json:"behavior_report_detailloans_latest_time"`
|
||||
}
|
||||
type CurrentReportDetail struct {
|
||||
LoansCreditLimit string `json:"current_report_detailloans_credit_limit"`
|
||||
LoansCredibility string `json:"current_report_detailloans_credibility"`
|
||||
LoansOrgCount string `json:"current_report_detailloans_org_count"`
|
||||
LoansProductCount string `json:"current_report_detailloans_product_count"`
|
||||
LoansMaxLimit string `json:"current_report_detailloans_max_limit"`
|
||||
LoansAvgLimit string `json:"current_report_detailloans_avg_limit"`
|
||||
ConsfinCreditLimit string `json:"current_report_detailconsfin_credit_limit"`
|
||||
ConsfinCredibility string `json:"current_report_detailconsfin_credibility"`
|
||||
ConsfinOrgCount string `json:"current_report_detailconsfin_org_count"`
|
||||
ConsfinProductCount string `json:"current_report_detailconsfin_product_count"`
|
||||
ConsfinMaxLimit string `json:"current_report_detailconsfin_max_limit"`
|
||||
ConsfinAvgLimit string `json:"current_report_detailconsfin_avg_limit"`
|
||||
}
|
||||
type ResultDetail struct {
|
||||
ApplyReportDetail ApplyReportDetail `json:"apply_report_detail"`
|
||||
BehaviorReportDetail BehaviorReportDetail `json:"behavior_report_detail"`
|
||||
CurrentReportDetail CurrentReportDetail `json:"current_report_detail"`
|
||||
}
|
||||
type Data struct {
|
||||
Code string `json:"code"`
|
||||
Desc string `json:"desc1"`
|
||||
TransID string `json:"trans_id"`
|
||||
TradeNo string `json:"trade_no"`
|
||||
Fee string `json:"fee"`
|
||||
IDNo string `json:"id_no"`
|
||||
IDName string `json:"id_name"`
|
||||
Versions string `json:"versions"`
|
||||
ResultDetail ResultDetail `json:"result_detail"`
|
||||
}
|
||||
|
||||
var data = `{
|
||||
"success": true,
|
||||
"data": {
|
||||
"code": "0",
|
||||
"desc": "查询成功",
|
||||
"trans_id": "14910304379231213",
|
||||
"trade_no": "201704011507240100057329",
|
||||
"fee": "Y",
|
||||
"id_no": "0783231bcc39f4957e99907e02ae401c",
|
||||
"id_name": "dd67a5943781369ddd7c594e231e9e70 ",
|
||||
"versions": "1.0.0",
|
||||
"result_detail":{
|
||||
"apply_report_detail": {
|
||||
"apply_score": "189",
|
||||
"apply_credibility": "84",
|
||||
"query_org_count": "7",
|
||||
"query_finance_count": "2",
|
||||
"query_cash_count": "2",
|
||||
"query_sum_count": "13",
|
||||
"latest_query_time": "2017-09-03",
|
||||
"latest_one_month": "1",
|
||||
"latest_three_month": "5",
|
||||
"latest_six_month": "12"
|
||||
},
|
||||
"behavior_report_detail": {
|
||||
"loans_score": "199",
|
||||
"loans_credibility": "90",
|
||||
"loans_count": "300",
|
||||
"loans_settle_count": "280",
|
||||
"loans_overdue_count": "20",
|
||||
"loans_org_count": "5",
|
||||
"consfin_org_count": "3",
|
||||
"loans_cash_count": "2",
|
||||
"latest_one_month": "3",
|
||||
"latest_three_month": "20",
|
||||
"latest_six_month": "23",
|
||||
"history_suc_fee": "30",
|
||||
"history_fail_fee": "25",
|
||||
"latest_one_month_suc": "5",
|
||||
"latest_one_month_fail": "20",
|
||||
"loans_long_time": "130",
|
||||
"loans_latest_time": "2017-09-16"
|
||||
},
|
||||
"current_report_detail": {
|
||||
"loans_credit_limit": "1400",
|
||||
"loans_credibility": "80",
|
||||
"loans_org_count": "7",
|
||||
"loans_product_count": "8",
|
||||
"loans_max_limit": "2000",
|
||||
"loans_avg_limit": "1000",
|
||||
"consfin_credit_limit": "1500",
|
||||
"consfin_credibility": "90",
|
||||
"consfin_org_count": "8",
|
||||
"consfin_product_count": "5",
|
||||
"consfin_max_limit": "5000",
|
||||
"consfin_avg_limit": "3000"
|
||||
}
|
||||
}
|
||||
},
|
||||
"errorCode": null,
|
||||
"errorMsg": null
|
||||
}`
|
||||
|
||||
func main() {
|
||||
struct1 := new(XinYanModel)
|
||||
err := json.Unmarshal([]byte(data), struct1)
|
||||
fmt.Println(err)
|
||||
fmt.Println(struct1)
|
||||
|
||||
fmt.Println()
|
||||
|
||||
struct2 := new(XinYanModel)
|
||||
j, err := gjson.DecodeToJson(data)
|
||||
fmt.Println(err)
|
||||
fmt.Println(j.Get("data.desc"))
|
||||
err = j.ToStruct(struct2)
|
||||
fmt.Println(err)
|
||||
fmt.Println(struct2)
|
||||
}
|
||||
69
.example/encoding/gjson/issue283.go
Normal file
69
.example/encoding/gjson/issue283.go
Normal file
@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
type GameUser struct {
|
||||
Uid int `json:"uid"`
|
||||
Account string `json:"account"`
|
||||
Tel string `json:"tel"`
|
||||
Role string `json:"role"`
|
||||
Vip int `json:"vip"`
|
||||
GameLevel int `json:"gamelevel"`
|
||||
Diamond int `json:"diamond"`
|
||||
Coin int `json:"coin"`
|
||||
Value int `json:"value"`
|
||||
Area string `json:"area"`
|
||||
ServerName string `json:"servername"`
|
||||
Time int `json:"time"`
|
||||
ClientInfo *ClientInfo `json:"client_info"`
|
||||
}
|
||||
|
||||
type ClientInfo struct {
|
||||
ClientGuid string `json:"client_guid"`
|
||||
ClientType int `json:"client_type"`
|
||||
ClientSDKVersion string `json:"client_sdk_version"`
|
||||
ClientVersion string `json:"client_version"`
|
||||
PackageId string `json:"packageid"`
|
||||
PhoneType string `json:"phone_type"`
|
||||
DevicesId string `json:"devices_id"`
|
||||
ClientMac string `json:"client_mac"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := `{
|
||||
"uid":9527,
|
||||
"account":"zhangsan",
|
||||
"tel":"15248787",
|
||||
"role":"test",
|
||||
"vip":7,
|
||||
"gamelevel":59,
|
||||
"diamond ":59,
|
||||
"coin ":59,
|
||||
"value ":99,
|
||||
"area":"s",
|
||||
"servername":"灵动",
|
||||
"time":15454878787,
|
||||
"client_info": {
|
||||
"client_guid": "aaaa",
|
||||
"client_type": 1,
|
||||
"client_sdk_version": "1.0.1",
|
||||
"client_version": "1.0.1",
|
||||
"packageid":"",
|
||||
"phone_type": "vivi",
|
||||
"devices_id":"",
|
||||
"client_mac":""
|
||||
}
|
||||
}`
|
||||
|
||||
gameUser := &GameUser{}
|
||||
err := gjson.DecodeTo(s, gameUser)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
}
|
||||
g.Dump(gameUser)
|
||||
|
||||
}
|
||||
44
.example/encoding/gparser/config.yaml
Normal file
44
.example/encoding/gparser/config.yaml
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
broker:
|
||||
ip: "127.0.0.1"
|
||||
tcpport: "4222"
|
||||
httpport: "8222"
|
||||
user: "alfxnats"
|
||||
pwd: "alfxnats"
|
||||
clusterid: "alfxnats"
|
||||
database:
|
||||
ip: "110.1.1.227"
|
||||
port: "27017"
|
||||
user: "alfxdev"
|
||||
pwd: "alfxdev"
|
||||
dbname: "alfxdev"
|
||||
scheduler:
|
||||
a2rparallel: 4
|
||||
sleeptime: 300
|
||||
worker:
|
||||
name: "worker1"
|
||||
domains:
|
||||
officenet: 3
|
||||
producnet: 3
|
||||
free: 3
|
||||
temppath: "/home/alfx/proc"
|
||||
common:
|
||||
filepath: "/home/alfx/file"
|
||||
logpath: "home/alfx/log"
|
||||
logdebug: true
|
||||
logtrace: true
|
||||
report:
|
||||
localip: "127.0.0.1"
|
||||
localport: ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/encoding/gparser"
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func getWithPattern1() {
|
||||
@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gogf/gf/g/encoding/gparser"
|
||||
import "github.com/gogf/gf/encoding/gparser"
|
||||
|
||||
func main() {
|
||||
xml := `<?xml version="1.0" encoding="GBK"?>
|
||||
77
.example/encoding/gparser/gparser_yaml_issue336.go
Normal file
77
.example/encoding/gparser/gparser_yaml_issue336.go
Normal file
@ -0,0 +1,77 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
Broker Broker
|
||||
Database Database
|
||||
Scheduler Scheduler
|
||||
Worker Worker
|
||||
Common Common
|
||||
Report Report
|
||||
}
|
||||
|
||||
type Broker struct {
|
||||
Ip string
|
||||
Tcport string
|
||||
Httpport string
|
||||
User string
|
||||
Pwd string
|
||||
Clusterid string
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
Ip string
|
||||
Port string
|
||||
User string
|
||||
Pwd string
|
||||
Dbname string
|
||||
}
|
||||
|
||||
type Scheduler struct {
|
||||
SleepTime int
|
||||
Pidfilepath string
|
||||
A2rparallel int
|
||||
}
|
||||
|
||||
type Worker struct {
|
||||
Name string
|
||||
Domains map[string]interface{}
|
||||
Temppath string
|
||||
Pidfilepath string
|
||||
}
|
||||
|
||||
type Common struct {
|
||||
Filepath string
|
||||
Logpath string
|
||||
Logdebug bool
|
||||
Logtrace bool
|
||||
}
|
||||
|
||||
type Report struct {
|
||||
Localip string
|
||||
Localport string //暂不启用
|
||||
}
|
||||
|
||||
func main() {
|
||||
_, err := gparser.Load("config.yaml")
|
||||
if err != nil {
|
||||
fmt.Println("oops,read config.yaml err:", err)
|
||||
}
|
||||
|
||||
//fmt.Println("yaml.v3读取yaml文件")
|
||||
//f, err := os.Open("config.yaml")
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//var conf Conf
|
||||
//err = yaml.NewDecoder(f).Decode(&conf)
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Println(conf)
|
||||
}
|
||||
30
.example/encoding/gyaml/gyaml.go
Normal file
30
.example/encoding/gyaml/gyaml.go
Normal file
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gyaml"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var yamlStr string = `
|
||||
#即表示url属性值;
|
||||
url: http://www.wolfcode.cn
|
||||
#即表示server.host属性的值;
|
||||
server:
|
||||
host: http://www.wolfcode.cn
|
||||
#数组,即表示server为[a,b,c]
|
||||
server:
|
||||
- 120.168.117.21
|
||||
- 120.168.117.22
|
||||
- 120.168.117.23
|
||||
#常量
|
||||
pi: 3.14 #定义一个数值3.14
|
||||
hasChild: true #定义一个boolean值
|
||||
name: '你好YAML' #定义一个字符串
|
||||
`
|
||||
|
||||
i, err := gyaml.Decode([]byte(yamlStr))
|
||||
fmt.Println(err)
|
||||
fmt.Println(i)
|
||||
}
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g/errors/gerror"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g/errors/gerror"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func OpenFile() error {
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g/errors/gerror"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/g/errors/gerror"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func OpenFile() error {
|
||||
@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gogf/gf/g/os/glog"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
|
||||
"github.com/gogf/gf/g/errors/gerror"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
4
.example/frame/main/model/config.toml
Normal file
4
.example/frame/main/model/config.toml
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
# MySQL数据库配置
|
||||
[database]
|
||||
link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
|
||||
13
.example/frame/main/model/model1.go
Normal file
13
.example/frame/main/model/model1.go
Normal file
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/.example/frame/mvc/model/test"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g.DB().SetDebug(true)
|
||||
user, err := test.ModelUser().One()
|
||||
g.Dump(err)
|
||||
g.Dump(user)
|
||||
}
|
||||
4
.example/frame/mvc/config.toml
Normal file
4
.example/frame/mvc/config.toml
Normal file
@ -0,0 +1,4 @@
|
||||
viewpath = "/home/www/templates"
|
||||
[redis]
|
||||
disk = "127.0.0.1:6379,0"
|
||||
cache = "127.0.0.1:6379,1"
|
||||
@ -1,8 +1,8 @@
|
||||
package demo
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/net/ghttp"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user