mirror of
https://gitee.com/johng/gf
synced 2026-06-08 02:27:42 +08:00
Compare commits
372 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8caf4ad21 | |||
| 51d9fe5253 | |||
| 3218c89f17 | |||
| 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 | |||
| a36e00efeb | |||
| bd4d273e1c | |||
| 216a928861 | |||
| a157c3f940 | |||
| 5a23459b23 | |||
| 538b282f43 | |||
| 86f51f1e4a | |||
| 622f76d5fb | |||
| 65e06b12ae | |||
| b714f7db69 | |||
| 1063922682 | |||
| 2c6168129a | |||
| 45465c1bd1 | |||
| 8acecc88f9 | |||
| 575349929b | |||
| 3913a89434 | |||
| 1bc8c9e3e2 | |||
| b4a0cca9c4 | |||
| 78b13ef4e1 | |||
| a49df101cd | |||
| 7ff4a00063 | |||
| 2636f8acf1 | |||
| 9042a885fa | |||
| ef837bd9c6 | |||
| 6a76725d64 | |||
| 697dbdc604 | |||
| 86f98f3710 | |||
| 470c696976 | |||
| e61bd174c8 | |||
| c71b9bc122 | |||
| c5339cbbe7 | |||
| 29020b0ac0 | |||
| 0a0530af0a | |||
| a5783ab860 | |||
| ae2de91b4c | |||
| ceecbef586 | |||
| 2fa558b25f | |||
| f465b478d6 | |||
| a4abac4916 | |||
| 9f9cb097d9 | |||
| 5ab64e31fd | |||
| ac6a8b9b74 | |||
| f43d252d08 | |||
| 185f9efb9c | |||
| 47d423036f | |||
| 7fae21f255 | |||
| 3fce835da0 | |||
| 0b62ccf941 | |||
| f7c5d7fc7f | |||
| e484685282 | |||
| 9c857705ff | |||
| 76f680de33 | |||
| 1181b6ae3a | |||
| 8a7f4ab156 | |||
| 99d43a7ddc | |||
| bd97d7d94e | |||
| 73235f1967 | |||
| 1ebc8092a6 | |||
| edd93c39a3 | |||
| 88c43d1772 | |||
| a0a8eb4700 | |||
| 28e5c33e81 | |||
| f24847576d | |||
| dfaf27e9e5 | |||
| 32d5b28423 | |||
| 0b8ca3313e | |||
| e6bb5e82a3 | |||
| a24b97b004 | |||
| 08eeff7f1c | |||
| 769f31e69a | |||
| cdf92b64d6 | |||
| 6d1ca028e7 | |||
| a228356399 | |||
| 3521f1b641 | |||
| 1dedf3d83b | |||
| da4c01c011 | |||
| 9cd445ad40 | |||
| ff4ef7e240 | |||
| 4de574ee86 | |||
| 0481b4025b | |||
| 9495b858fd | |||
| 5576adbd0b | |||
| b8da86bce8 | |||
| a926d3dadd | |||
| a95624ab19 | |||
| cf745422f3 | |||
| 10e042454c | |||
| 759be06ebc | |||
| aea37272ea | |||
| 2f17d37f7b | |||
| df8623c4e2 | |||
| 5c9766fb1b | |||
| a3d2e03425 | |||
| 717dae8f5d | |||
| 373dbde42c | |||
| 125af33941 | |||
| b43e36a79d | |||
| 145fccdf6e | |||
| f9c478f250 | |||
| 5da822fdc4 | |||
| 5abf1b5742 | |||
| 9ac3841342 | |||
| 1f315c5b8d | |||
| b9440587d0 | |||
| 835a971f89 | |||
| 0bba2092af | |||
| c3240218f8 | |||
| 9e392985b8 | |||
| a7d30dd1d5 | |||
| fa96d881e1 | |||
| 9ca9d6c4bd | |||
| 7ad66db491 | |||
| 1dbda3872b | |||
| 3619a46f52 | |||
| 6a93d166c5 | |||
| c84e62febe | |||
| 8ff21d6936 | |||
| 3b0012ec30 | |||
| 62a3f1693d | |||
| ed6796dde0 | |||
| 46721d7552 | |||
| a9a5a78e02 | |||
| 7c4431ceeb | |||
| 8cfdc8f27f | |||
| 691baf5c16 | |||
| b439aedce5 | |||
| 2504e405a7 | |||
| 6426409bf9 | |||
| 9cf4ea5c91 | |||
| 86343abcf8 | |||
| c6f94ed95a | |||
| 949ac459fc | |||
| 32fc6868aa | |||
| 82394cd70e | |||
| 1c71340719 | |||
| 363dede57c | |||
| 105cdf6fe6 | |||
| 5135264d56 | |||
| c3ff1a3db3 | |||
| d62c1dedf3 | |||
| bd105a188f | |||
| 09affd3981 | |||
| 8e7e18e22d | |||
| e03fd80fd4 | |||
| adc3201dcf | |||
| 3a681e5b1a | |||
| 285b45d19d | |||
| 783f1c8457 | |||
| daa7f12994 | |||
| 5d464494b6 | |||
| 4ca2513d00 | |||
| 15d69ed950 | |||
| 39bd2616c4 | |||
| 6302789c41 | |||
| 5c7b25c960 | |||
| 10102f2db9 | |||
| 6f5b5e4dc2 | |||
| 007c8a7b64 | |||
| 009ce9063e | |||
| 58a405bfa8 | |||
| 42214f17fc | |||
| b5f117e932 | |||
| b0f158047c | |||
| d5f7ca634d | |||
| 0801245871 | |||
| 278fd3515f | |||
| 56588f3f7f | |||
| a5d01cb547 | |||
| fabf5d1ad5 | |||
| ebae3a4929 | |||
| e4c42bde89 | |||
| f7515edde9 | |||
| 04c422c3af | |||
| 339ca74ff4 | |||
| 741a13379a | |||
| 055c6a668e | |||
| 735c5fc7ed | |||
| 3bfff2347f | |||
| 7d83604540 | |||
| adf2ddb510 | |||
| f30c9020fa | |||
| 1b3073f3f9 | |||
| 615161ac9d | |||
| 02e06e7c6e | |||
| d15268eb22 | |||
| e48415d932 | |||
| e5fa341f39 | |||
| 234d734981 | |||
| d771ed9209 | |||
| 37d72cb8b3 | |||
| 1154f9601b | |||
| 322513f99b | |||
| 6e7ac60d4d | |||
| 405840607f | |||
| 8417e7ef65 | |||
| ac2fe44d8e | |||
| 3030d7f032 | |||
| d74034e08e | |||
| d41cc7c3b6 | |||
| 3120d0bd7a | |||
| 7bebf062be | |||
| 6c657dff37 | |||
| 5896dadaad |
@ -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()
|
||||
|
||||
// 设置键值对
|
||||
24
.example/container/gmap/gmap_json.go
Normal file
24
.example/container/gmap/gmap_json.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//m := gmap.New()
|
||||
//m.Set("k", "v")
|
||||
//m.Set("1", "2")
|
||||
//b, err := json.Marshal(m)
|
||||
//fmt.Println(err)
|
||||
//fmt.Println(string(b))
|
||||
|
||||
m := gmap.NewIntIntMap()
|
||||
m.Set(1, 2)
|
||||
m.Set(3, 4)
|
||||
b, err := json.Marshal(m)
|
||||
fmt.Println(err)
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
@ -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() {
|
||||
8
.example/database/gdb/mssql/config.toml
Normal file
8
.example/database/gdb/mssql/config.toml
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
[database]
|
||||
type = "mssql"
|
||||
host = "127.0.0.1"
|
||||
port = "1451"
|
||||
user = "sa"
|
||||
pass = "eno@123"
|
||||
name = "frpc"
|
||||
14
.example/database/gdb/mssql/gdb_all.go
Normal file
14
.example/database/gdb/mssql/gdb_all.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r, err := g.DB().GetAll(`SELECT TOP 10 * FROM KF_PatInfo_Emergency`)
|
||||
fmt.Println(err)
|
||||
g.Dump(r.ToList())
|
||||
}
|
||||
@ -3,9 +3,10 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"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数据库操作示例,不作为单元测试使用
|
||||
@ -26,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 {
|
||||
@ -49,7 +50,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.2",
|
||||
@ -59,7 +60,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.3",
|
||||
@ -69,7 +70,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.4",
|
||||
@ -79,7 +80,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
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
.example/database/gdb/mysql/config2.toml
Normal file
4
.example/database/gdb/mysql/config2.toml
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
# MySQL数据库配置
|
||||
[database]
|
||||
link = "mysql:root:8692651@tcp(192.168.1.11:3306)/test"
|
||||
7
.example/database/gdb/mysql/config3.toml
Normal file
7
.example/database/gdb/mysql/config3.toml
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
# MySQL数据库配置
|
||||
[database]
|
||||
[database.default]
|
||||
link = "mysql:root:8692651@tcp(192.168.1.11:3306)/test"
|
||||
[database.user]
|
||||
link = "mysql:root:8692651@tcp(192.168.1.11:3306)/test"
|
||||
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
"github.com/gogf/gf/g/database/gdb"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mysql数据库操作示例,不作为单元测试使用
|
||||
@ -25,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 {
|
||||
@ -48,7 +49,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.2",
|
||||
@ -58,7 +59,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.3",
|
||||
@ -68,7 +69,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.4",
|
||||
@ -78,7 +79,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
21
.example/database/gdb/mysql/gdb_all.go
Normal file
21
.example/database/gdb/mysql/gdb_all.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
r, e := db.Table("test").OrderBy("id asc").All()
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if r != nil {
|
||||
fmt.Println(r.ToList())
|
||||
}
|
||||
}
|
||||
23
.example/database/gdb/mysql/gdb_args_slice.go
Normal file
23
.example/database/gdb/mysql/gdb_args_slice.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
|
||||
db.Table("user").Where("nickname like ? and passport like ?", g.Slice{"T3", "t3"}).OrderBy("id asc").All()
|
||||
|
||||
conditions := g.Map{
|
||||
"nickname like ?": "%T%",
|
||||
"id between ? and ?": g.Slice{1, 3},
|
||||
"id >= ?": 1,
|
||||
"create_time > ?": 0,
|
||||
"id in(?)": g.Slice{1, 2, 3},
|
||||
}
|
||||
db.Table("user").Where(conditions).OrderBy("id asc").All()
|
||||
|
||||
var params []interface{}
|
||||
db.Table("user").Where("1=1", params).OrderBy("id asc").All()
|
||||
}
|
||||
@ -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() {
|
||||
20
.example/database/gdb/mysql/gdb_bit.go
Normal file
20
.example/database/gdb/mysql/gdb_bit.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
|
||||
r, e := db.Table("test").All()
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if r != nil {
|
||||
fmt.Println(r.ToList())
|
||||
}
|
||||
}
|
||||
@ -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,11 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g.Config().AddPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/geg/frame")
|
||||
if r, err := g.DB().Table("user").Where("uid=?", 1).One(); err == nil {
|
||||
fmt.Println(r["uid"].Int())
|
||||
fmt.Println(r["name"].String())
|
||||
17
.example/database/gdb/mysql/gdb_config2.go
Normal file
17
.example/database/gdb/mysql/gdb_config2.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g.Config().SetFileName("config2.toml")
|
||||
if r, err := g.DB().Table("user").Where("uid=?", 1).One(); err == nil {
|
||||
fmt.Println(r["uid"].Int())
|
||||
fmt.Println(r["name"].String())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
24
.example/database/gdb/mysql/gdb_config3.go
Normal file
24
.example/database/gdb/mysql/gdb_config3.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
g.Config().SetFileName("config3.toml")
|
||||
if r, err := g.DB().Table("user").Where("uid=?", 1).One(); err == nil {
|
||||
fmt.Println(r["uid"].Int())
|
||||
fmt.Println(r["name"].String())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
if r, err := g.DB("user").Table("user").Where("uid=?", 1).One(); err == nil {
|
||||
fmt.Println(r["uid"].Int())
|
||||
fmt.Println(r["name"].String())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
@ -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() {
|
||||
@ -24,8 +24,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
db.SetDebug(true)
|
||||
db.Table("user").Limit(2).Delete()
|
||||
return
|
||||
|
||||
glog.SetPath("/tmp")
|
||||
|
||||
// 执行3条SQL查询
|
||||
17
.example/database/gdb/mysql/gdb_debug2.go
Normal file
17
.example/database/gdb/mysql/gdb_debug2.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
// 执行3条SQL查询
|
||||
for i := 1; i <= 3; i++ {
|
||||
db.Table("user").Where("id=?", i).One()
|
||||
}
|
||||
// 构造一条错误查询
|
||||
db.Table("user").Where("no_such_field=?", "just_test").One()
|
||||
|
||||
db.Table("user").Data(g.Map{"name": "smith"}).Where("uid=?", 1).Save()
|
||||
}
|
||||
@ -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()
|
||||
@ -3,9 +3,10 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"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数据库操作示例,不作为单元测试使用
|
||||
@ -25,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 {
|
||||
@ -48,7 +49,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.2",
|
||||
@ -58,7 +59,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.3",
|
||||
@ -68,7 +69,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.4",
|
||||
@ -78,7 +79,7 @@ func init() {
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Priority : 100,
|
||||
// Weight : 100,
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
@ -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)
|
||||
}
|
||||
25
.example/errors/gerror/gerror1.go
Normal file
25
.example/errors/gerror/gerror1.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
return errors.New("test1")
|
||||
}
|
||||
|
||||
func Error2() error {
|
||||
return gerror.New("test2")
|
||||
}
|
||||
|
||||
func main() {
|
||||
err1 := Error1()
|
||||
err2 := Error2()
|
||||
fmt.Printf("%s, %-s, %+s\n", err1, err1, err1)
|
||||
fmt.Printf("%v, %-v, %+v\n", err1, err1, err1)
|
||||
fmt.Printf("%s, %-s, %+s\n", err2, err2, err2)
|
||||
fmt.Printf("%v, %-v, %+v\n", err2, err2, err2)
|
||||
}
|
||||
26
.example/errors/gerror/gerror2.go
Normal file
26
.example/errors/gerror/gerror2.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func OpenFile() error {
|
||||
return gerror.New("permission denied")
|
||||
}
|
||||
|
||||
func OpenConfig() error {
|
||||
return gerror.Wrap(OpenFile(), "configuration file opening failed")
|
||||
}
|
||||
|
||||
func ReadConfig() error {
|
||||
return gerror.Wrap(OpenConfig(), "reading configuration failed")
|
||||
}
|
||||
|
||||
func main() {
|
||||
//err := ReadConfig()
|
||||
//glog.Printf("%s\n%+s", err, err)
|
||||
//glog.Printf("%+v", err)
|
||||
fmt.Printf("%+v", ReadConfig())
|
||||
}
|
||||
23
.example/errors/gerror/gerror3.go
Normal file
23
.example/errors/gerror/gerror3.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
return errors.New("test1")
|
||||
}
|
||||
|
||||
func Error2() error {
|
||||
return gerror.New("test2")
|
||||
}
|
||||
|
||||
func main() {
|
||||
err1 := Error1()
|
||||
err2 := Error2()
|
||||
fmt.Println("err1:\n", gerror.Stack(err1))
|
||||
fmt.Println("err2:\n", gerror.Stack(err2))
|
||||
}
|
||||
23
.example/errors/gerror/gerror4.go
Normal file
23
.example/errors/gerror/gerror4.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func OpenFile() error {
|
||||
return gerror.New("permission denied")
|
||||
}
|
||||
|
||||
func OpenConfig() error {
|
||||
return gerror.Wrap(OpenFile(), "configuration file opening failed")
|
||||
}
|
||||
|
||||
func ReadConfig() error {
|
||||
return gerror.Wrap(OpenConfig(), "reading configuration failed")
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(gerror.Cause(ReadConfig()))
|
||||
}
|
||||
22
.example/errors/gerror/gerror5.go
Normal file
22
.example/errors/gerror/gerror5.go
Normal file
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gogf/gf/os/glog"
|
||||
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
)
|
||||
|
||||
func Error1() error {
|
||||
return errors.New("test1")
|
||||
}
|
||||
|
||||
func Error2() error {
|
||||
return gerror.New("test2")
|
||||
}
|
||||
|
||||
func main() {
|
||||
glog.Println(Error1())
|
||||
glog.Println(Error2())
|
||||
}
|
||||
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