Compare commits

...

264 Commits

Author SHA1 Message Date
58b2efc900 version update 2019-10-24 21:05:23 +08:00
28326606f5 fix issue in resource file handler for ghttp.Server 2019-10-24 20:22:37 +08:00
91c98bbb60 fix issue in group router feature for domain 2019-10-24 19:44:30 +08:00
c0236d7dfa improve gstr.SplitAndTrim 2019-10-22 13:57:21 +08:00
d4051df5b6 improve gdb/gstr/gconv/garray 2019-10-21 19:13:25 +08:00
88045417ff fix issue in field type check for gdb 2019-10-17 20:57:49 +08:00
500efb5601 fix issue in template for ghttp.Server 2019-10-17 20:31:03 +08:00
97fe8235da fix issue in session expiring for file storage of gsession; add Pop/Pops functions for gset/gmap 2019-10-16 23:33:06 +08:00
e1164e935b improve configuration for gdb; add more unit test case for ghttp.Server 2019-10-15 21:20:38 +08:00
b26330aee1 rename cacheTime to cacheExpire and change its type from int to time.Duration for gdb.Model; fix issue in string support of function Data for gdb 2019-10-15 17:44:47 +08:00
2b083709b5 add gmap.ListMap/TreeMap support for gdb.Where 2019-10-14 23:27:48 +08:00
0ac45dc379 rename file name from link_map to list_map for package gmap 2019-10-14 22:43:31 +08:00
650916c22a version updates 2019-10-14 13:46:45 +08:00
2804183325 fix issue in content-type response for ghttp.Server 2019-10-14 13:46:16 +08:00
2dc2610621 improve gdb; README update 2019-10-13 23:05:48 +08:00
1736e71e6b add debug for unit test case of 2019-10-13 22:40:23 +08:00
69ee5375b9 improve Join/String functions for garray/gset/gmap; add AddIfNotExistFunc/AddIfNotExistFuncLock functions for gset 2019-10-13 22:31:28 +08:00
3ac0a66887 improve unit test cases for gspath 2019-10-13 21:42:04 +08:00
20e873a1fc version updates 2019-10-13 00:40:06 +08:00
142484d89c add support for like statement in map key for Where function, improve error format for gdb 2019-10-13 00:37:25 +08:00
76a9f4ca14 fix security issue in static file feature for ghttp.Server 2019-10-12 23:56:03 +08:00
c4e5679d5c fix issue in missing passing MaxIdle/MaxActive configuration to underlying redis pool for gredis; add extra output for unit test cases of ghttp.Server 2019-10-11 23:33:21 +08:00
b08d7c3c38 change Join function feature for garray 2019-10-11 23:17:29 +08:00
5092d8e6c5 improve status handling and add error logger for ghttp.Server; fix issue in defer error warpping for some packages 2019-10-11 22:54:25 +08:00
74d625ff97 add Get*Int32/Get*Int64/Get*Uint32/Get*Uint64 functions for ghttp.Request 2019-10-10 10:40:38 +08:00
f1119e28e8 add Get*Int32/Get*Int64/Get*Uint32/Get*Uint64 functions for ghttp.Request 2019-10-10 10:33:14 +08:00
3082c7f761 fix issue in StrLimit for gstr 2019-10-10 00:04:38 +08:00
5f36614dd7 remove UseNumber for json decoding in package gjson 2019-10-09 20:33:26 +08:00
1dcc7a4887 improve http status handling for middleware of ghttp.Server 2019-10-09 15:26:50 +08:00
41e9d35487 improve middleware feature for ghttp.Server; fix issue memory usage in big file downloading 2019-10-09 00:33:58 +08:00
977c8b7ee3 version updates 2019-10-01 17:54:29 +08:00
939e6244ee comment update for gtcp/gudp 2019-10-01 17:53:49 +08:00
e764b2393d change params order of Insert* functions for glist; improve gstr.IsNumber 2019-10-01 16:35:44 +08:00
6384e75ed9 improva container for json marshal/unmarshal interface 2019-10-01 16:03:18 +08:00
195cae6577 add new functions and mark deprecated for some functions for gdb 2019-10-01 11:29:02 +08:00
c8cf46a5a7 add Create function for gvar; add Uints/SliceUint function for gconv 2019-10-01 10:42:34 +08:00
eba97277b2 add more unit test cases for ghttp 2019-10-01 09:33:26 +08:00
4e19fbc5fb add separate put/delete functions for ghttp.Request 2019-10-01 09:06:35 +08:00
494b5bbae2 fix issue in unit test case for gvar 2019-09-30 17:30:24 +08:00
987ce709e5 add UnmarshalJSON for gtime; add ineterface MapStrAny support for gjson.New 2019-09-30 17:23:23 +08:00
35ad4d869f fix issue in cycle import for gtime 2019-09-30 15:51:15 +08:00
39d654e3f2 update comment for gtime 2019-09-30 15:26:32 +08:00
7fe9c641f4 add UnmarshalJSON func tion for gset 2019-09-30 14:37:05 +08:00
ee1414c010 add UnmarshalJSON func tion for gmap/gvar 2019-09-30 14:23:15 +08:00
8eb1b685a5 improve UnmarshalJSON function for garray 2019-09-29 22:16:36 +08:00
46768d6f91 add UnmarshalJSON function and corresponding unit test cases for package grray 2019-09-29 20:47:59 +08:00
bb6fed3dc2 add UnmarshalJSON function and corresponding unit test cases for package gtype 2019-09-29 20:12:59 +08:00
47e74d27bf add MarshalJSON function to implement the interface MarshalJSON for json.Marshal for gtype 2019-09-29 15:59:09 +08:00
b830f9b96d improve ghttp.Server.Request for parameter retrieving; add Option feature for gdb; update example for hook feature of ghttp.Server 2019-09-29 14:27:09 +08:00
c85162a8a0 improving gdb.Model/gmap 2019-09-26 20:01:48 +08:00
ef4e128af7 fix issue in cors 2019-09-26 15:54:13 +08:00
cb7c3a9fa4 fix issue in index folder feature for ghttp.Server 2019-09-25 10:56:44 +08:00
b0f859cc91 improve example codes 2019-09-24 23:41:18 +08:00
6d4da529ee add websocket unit test case for ghttp 2019-09-24 21:08:28 +08:00
6c7e536eeb fix issue in gbase64/ghttp 2019-09-24 20:39:00 +08:00
36c2648be8 improve ghttp.Response; move gflock to new repo 2019-09-24 20:19:18 +08:00
a876b6133d fix issue in unit test case og grand 2019-09-23 23:24:36 +08:00
03ff358da8 update ci/readme/donator 2019-09-23 23:08:58 +08:00
037f74c549 Create FUNDING.yml 2019-09-23 22:32:31 +08:00
a8caf4ad21 RELEASE updates 2019-09-23 22:00:04 +08:00
51d9fe5253 add AllowDomain option for ghttp.CORS; add IsSubDomain function for gstr; improve grand.Intn 2019-09-23 19:25:03 +08:00
3218c89f17 improve gfile/gstr/ghttp 2019-09-23 16:21:19 +08:00
02e467fb57 rename MapStruct* functions to MapToMap* for gconv and according packags 2019-09-19 23:23:41 +08:00
ec994f3080 add more examples of middleware feature for ghttp.Server; release updates 2019-09-19 21:17:54 +08:00
1181ab499c improve error handling in hook feature for ghttp.Server 2019-09-19 20:25:01 +08:00
5424935fd9 rename AddMiddleware to BindMiddleWareDefault for ghttp.Server; add more unit test cases fpr gstr 2019-09-19 20:19:07 +08:00
b9fbfb91bd improve middleware feature of ghttp.Server; add MapStrAny function for gmap/gtree 2019-09-19 19:44:46 +08:00
62f66b4fec remove unnecessary stack trace of gf for stack printing 2019-09-19 13:13:39 +08:00
eef9da9a41 improve parameters parsing for ghttp.Server 2019-09-19 09:09:12 +08:00
7d32be3b6c improve perameter parsing for ghttp.Server 2019-09-18 23:20:45 +08:00
c2ad9f5fb9 fix issue in gyaml for invalid decoding result of type map[interface{}]interface{} 2019-09-17 20:53:20 +08:00
4847fecdaa Merge branch 'master' of https://github.com/gogf/gf 2019-09-17 19:48:19 +08:00
f75383e0c5 fix issue in quote word for gdb 2019-09-17 19:45:51 +08:00
f683dccb6f Merge pull request #335 from LetMyPplGo/master
added tests for gsmtp
2019-09-17 10:44:15 +08:00
6fb106b618 added tests for gsmtp 2019-09-17 00:06:46 +03:00
97956ad903 version/release update 2019-09-16 23:07:57 +08:00
5d72a5b5ae improve gcmd 2019-09-16 20:57:43 +08:00
1d7ded562c add quote support for table named with '.'; improve case conversion for strings named with '.' for gstr 2019-09-16 17:15:39 +08:00
0d87b601cc fix issue in data filter for gdb.Model 2019-09-16 16:54:52 +08:00
33fbedffb8 gix issue in Config variable for ghttp.Response.View 2019-09-16 15:49:31 +08:00
2cfcbc82e1 RELEASE updates 2019-09-16 11:10:38 +08:00
e1721cb1b6 add package gmode for release mode management 2019-09-16 11:08:41 +08:00
1d264a6545 add package gmode for release mode management; add error returning for template rendoring for gmvc.View/ghttp.Response 2019-09-16 10:44:07 +08:00
565e48f6f1 add more example for package gres; RELEASE updates 2019-09-15 21:47:47 +08:00
2b20c77bc0 improve example for gi18n 2019-09-15 13:47:44 +08:00
1665d92136 improve session expire algorithm for gsession 2019-09-15 12:17:44 +08:00
f128cb9f61 improve session storage interface for gsession 2019-09-15 11:30:38 +08:00
6d55b30b39 add example for group router of ghttp.Server 2019-09-14 23:36:02 +08:00
953ea55899 improve status handling for response of ghttp.Server 2019-09-14 22:57:57 +08:00
966c93af00 improve middleware and error logging for ghttp.Server 2019-09-14 22:53:28 +08:00
41a0b52939 RELEASE updates 2019-09-14 00:43:06 +08:00
8281d9cdd1 improve gfile.MainPkgPath; update RELEASE.MD 2019-09-14 00:17:49 +08:00
b0ece3bd8f Merge branch 'master' of https://github.com/gogf/gf 2019-09-13 22:14:08 +08:00
19a856549a improve codes details 2019-09-13 22:08:18 +08:00
65bd31bb65 Merge pull request #316 from LetMyPplGo/master 2019-09-13 21:16:16 +08:00
a3830f0820 Merge pull request #326 from wenzi1/master 2019-09-13 21:15:22 +08:00
5f8656eb41 Merge pull request #332 from hailaz/master
improve dbBase.doBatchInsert()
2019-09-13 21:14:38 +08:00
141bee9c49 add ConfigByMap function for ghttp.Server; improve gsession for file storage 2019-09-13 20:49:16 +08:00
aa44c0fb11 improve session for ghttp.Server; improve i18n for gview 2019-09-12 00:00:59 +08:00
79e2d30849 improve gsession for file storing 2019-09-11 23:26:38 +08:00
e8a9c7ac72 update comments for package gaes/gdes; update function names for gdes 2019-09-11 23:22:15 +08:00
006054d13a fix issue in session for ghttp.Server 2019-09-11 22:57:29 +08:00
b39d653fe9 add package gsession; mv gkvdb to new repo 2019-09-11 21:19:45 +08:00
d9e7d4249f improve dbBase.doBatchInsert() 2019-09-11 16:48:00 +08:00
34ad4ae166 Merge pull request #7 from gogf/master
sync master
2019-09-11 16:40:27 +08:00
69684f5023 improve gredis instance initialization for gins 2019-09-10 20:38:23 +08:00
2ed1854f0c improve gres with file separator replaced to / 2019-09-10 14:21:11 +08:00
09da0f7388 improving gview with ghttp for controller 2019-09-09 23:02:40 +08:00
7f943c6b5f improving gview with i18n 2019-09-09 22:56:54 +08:00
ed3fc529ed Failed to return when Gini file grammar error
Failed to return when Gini file grammar error
2019-09-08 23:25:45 +08:00
2eb0511ef5 Failed to return when Gini file grammar error
Failed to return when Gini file grammar error
2019-09-08 23:24:00 +08:00
8bc1f457c7 Merge pull request #1 from gogf/master
update
2019-09-08 22:58:40 +08:00
77a727e1d7 improve i18n with gview 2019-09-08 21:12:11 +08:00
16cc3c0fca fix issue in gredis unit test cases 2019-09-06 18:08:58 +08:00
96106ace92 remove deprecated functions and fix corresponding unit test cases 2019-09-06 17:59:55 +08:00
13e528abb6 remove deprecated functions and fix corresponding unit test cases 2019-09-06 16:59:38 +08:00
0d5dfe59b9 remove deprecated functions 2019-09-06 16:44:40 +08:00
8fd88307f7 add errors printing when i18n files loading failed for gi18n 2019-09-06 15:43:57 +08:00
57244a9553 added the example for gsmtp 2019-09-06 01:18:41 +03:00
fb8aac38dd server address verification
simple Email address check for from & to
default port=25 for server address
2019-09-06 00:53:23 +03:00
8f953dabe5 fix issue in ghttp.Session.GetMap* 2019-09-05 23:48:54 +08:00
d63c2882fd update unit test case for gfile.IsEmpty 2019-09-05 20:18:49 +08:00
952eb7df15 add Scan/Scanf functions for gcmd; improve gfile.IsEmpty 2019-09-05 20:00:01 +08:00
dfc76ddb76 add IsEmpty function for gfile 2019-09-05 19:22:11 +08:00
b0cddc29e4 add more functions for gcmd 2019-09-05 15:16:25 +08:00
dfc61cb273 rename StrArray to StrArray for garray 2019-09-05 14:26:08 +08:00
05922e4f21 add more common types for package g 2019-09-05 14:25:20 +08:00
6cf4bf81e5 improve gcmd with arguments parser 2019-09-05 11:38:36 +08:00
ad43989944 improve procedure of ghttp.Server 2019-09-04 20:22:31 +08:00
31e7037e3e add example for session handling of ghttp 2019-09-04 20:12:29 +08:00
425d45e502 improve error text for session saving error 2019-09-04 20:04:04 +08:00
9ddb148fcb fix issue in memory usage of gkvdb in unit test cases of ghttp 2019-09-04 19:44:13 +08:00
e4d34abd7e fix unit test cases for ghttp/gres 2019-09-04 19:23:19 +08:00
16103c43eb fix unit test cases for ghttp/gres 2019-09-04 19:10:15 +08:00
7fad4b686c improve gcompress/gres for packing files 2019-09-03 23:18:54 +08:00
cd00ac446b improve CORS feature for ghttp.Server 2019-09-03 17:18:16 +08:00
e2906fba0b improve type conversion for gdb 2019-09-03 00:06:24 +08:00
acd5e72f6c improve gdb for configiration 2019-09-02 20:35:29 +08:00
8f1fd259d4 Merge branch 'master' of https://github.com/gogf/gf 2019-09-02 19:06:53 +08:00
d9041da426 Merge branch 'develop' 2019-09-02 19:06:01 +08:00
269ddb04af fix issue in gfile.Replace* 2019-09-02 19:05:32 +08:00
b1c2b9f4e0 improve gconv.Bool for NO/YES; improve gdb for model generation 2019-09-02 15:48:25 +08:00
7e9fe8ea98 improve resource feature in ghttp.Server 2019-09-01 22:22:08 +08:00
af81bf2bde Merge branch 'develop' 2019-09-01 22:14:45 +08:00
55addaa8ea improve gres and add more unit test cases for gres 2019-09-01 22:14:31 +08:00
6ccc4d119f improve export data as hex for gres 2019-09-01 21:34:15 +08:00
c05a91cdc9 README update 2019-09-01 00:31:15 +08:00
077d8b9f48 Merge branch 'develop' 2019-09-01 00:30:19 +08:00
15a6680833 add package gi18n 2019-09-01 00:30:01 +08:00
6c61704e60 adding package gi18n 2019-08-31 18:04:12 +08:00
cfa0b99cd8 README update 2019-08-30 22:19:50 +08:00
c0bb8bef06 README update 2019-08-30 22:15:54 +08:00
86f9d5c39d README update 2019-08-30 22:15:13 +08:00
33f2ae5fc4 fix spell issue of const names for gproc 2019-08-30 21:07:46 +08:00
ea1277d76c add case functions for gstr and according unit test cases 2019-08-30 20:51:23 +08:00
ee89a06b3e improve model feature 2019-08-30 20:29:12 +08:00
a31108e753 fix issue in gring/ghttp 2019-08-26 23:51:01 +08:00
2bf9bc98a7 improve gkvdb, container 2019-08-26 23:35:44 +08:00
d67975249c fix issue in unit test case for gkvdb 2019-08-26 22:54:59 +08:00
d3a2bef9ba improve debug sql with arguments auto bound 2019-08-26 20:57:37 +08:00
b7f67e3162 add StackWithFilter function for glog, and improve gdb/ghttp 2019-08-26 20:09:24 +08:00
1a20edc0b0 improving gdb and glog 2019-08-26 19:39:04 +08:00
f80ba1473e fix issue in stack skip feature for glog; fix issue in slice parameter for gdb 2019-08-24 23:08:17 +08:00
89a8203949 comment update for gpage 2019-08-22 23:30:28 +08:00
fd6321e71b update donator; update unit test case for gdb; fix issue in bool convertion for []byte for gconv 2019-08-22 23:24:45 +08:00
7dffd9d1ff add package gkvdb; add kvdb storage feature for ghttp.Server 2019-08-22 21:04:30 +08:00
51a156420d improve gres for empty path passed 2019-08-19 22:54:37 +08:00
c92323c681 gofmt 2019-08-19 22:42:31 +08:00
10e03eef3b add resource feature for gcfg 2019-08-19 21:02:44 +08:00
e151055521 improve resource feature for ghttp/gview 2019-08-19 20:17:13 +08:00
1f8408b622 improve gdb 2019-08-19 19:21:27 +08:00
98ddadb131 Merge branch 'master' of https://github.com/gogf/gf into develop 2019-08-19 19:09:48 +08:00
a5ac12545a Merge pull request #286 from wenzi1/master 2019-08-19 19:07:46 +08:00
e58384d815 update example for gres 2019-08-16 00:37:12 +08:00
ab381dacfe add resource feature support for gview 2019-08-16 00:29:14 +08:00
9162fde14a improve resource feature for ghttp.Server 2019-08-15 19:27:32 +08:00
6cf1714a07 improve resource feature for ghttp.Server 2019-08-15 19:20:39 +08:00
c402e17605 修改mssql中的datetime类型的处理 2019-08-14 22:44:57 +08:00
25746e9844 adding gres 2019-08-14 22:18:31 +08:00
a8a8dbeab8 adding gres 2019-08-14 22:16:33 +08:00
6113df2b3e adding gres 2019-08-14 22:03:52 +08:00
8f7363df41 删除mssql中的convertValue方法。
修改测试案例中的datetime类型的字段在查到数据后做转换
2019-08-14 19:16:45 +08:00
dafc79bf80 adding gres 2019-08-14 00:13:42 +08:00
9ae537cafc adding gres 2019-08-13 21:06:11 +08:00
162df6b250 fix issue in number overflow from int64 to int for ghttp.Session/ghttp.Cookie/gcache 2019-08-13 20:15:09 +08:00
12f28dfc95 improving gtree/gres 2019-08-13 13:45:01 +08:00
5d7d8abbde add oracle/mssql/postgres unit test cases 2019-08-12 17:12:16 +08:00
b960faec45 to support automated testing of postgres 2019-08-12 16:57:08 +08:00
9a057b757d add package gini 2019-08-12 16:53:07 +08:00
296c4b750b add oracle/mssql/postgres unit test cases 2019-08-12 16:50:57 +08:00
7ecc47e127 adding gres package for resource feature 2019-08-10 23:36:38 +08:00
d03180ff4d Merge pull request #284 from pibigstar/master
feat(travis): exit ci when test failed
2019-08-10 21:17:16 +08:00
c1c52b072e feat(travis): exit ci when test failed 2019-08-10 19:55:01 +08:00
72be3803ec update unit test cases for ghttp 2019-08-10 18:07:24 +08:00
5cb4a8557d fix issue for unit test case of gutil 2019-08-10 17:59:34 +08:00
7787135549 improve status checks if there're middlewares registed for ghttp.Server 2019-08-10 17:46:11 +08:00
56368500a3 add header support for session feature of ghttp.Server 2019-08-10 16:39:46 +08:00
846c6a579e improve ghttp.RouterGroup 2019-08-10 14:10:47 +08:00
573179060e improve gjson 2019-08-09 20:33:21 +08:00
fda345577a add package gdebug; improve gconv/gfile/gset 2019-08-09 20:05:36 +08:00
8387710473 fix issue in gset.Pop; improve internal/debug 2019-08-09 09:51:56 +08:00
3af3fd1428 fix issue in gset.Pop; improve internal/debug 2019-08-09 09:51:52 +08:00
c7c6e2866e add Unsafe* functions for gconv 2019-08-09 09:14:48 +08:00
7172ae0232 fix issue in invalid error stacks for glog; improve internal/debug and gutil for stack printing 2019-08-08 22:58:49 +08:00
4eac97a7d8 add Master/Slave functions for gdb 2019-08-08 17:43:21 +08:00
352e4c088a improve gcfg: it returns all values if pattern is '.'; add more functions for gcfg 2019-08-07 16:58:01 +08:00
4d5814fc43 improve grand 2019-08-07 16:21:31 +08:00
6d13b91d37 improve grand 2019-08-07 16:20:19 +08:00
0376c99b5a update unit test cases for ghttp 2019-08-06 23:10:37 +08:00
77d9e472b7 add middleware feature for ghttp.Server; improve router group feature for ghttp.Server 2019-08-06 20:40:04 +08:00
2911ebb5d7 add middleware feature for ghttp.Server 2019-08-03 23:57:20 +08:00
f4d01f56c6 add middleware feature for ghttp.Server 2019-08-03 18:08:10 +08:00
878305fee3 add middleware feature for ghttp.Server 2019-08-03 17:14:54 +08:00
0460a53f53 add middleware feature for ghttp.Server 2019-08-03 15:54:12 +08:00
e622f6aff2 improve gconv to support struct field of interface{} conversion 2019-08-01 19:53:28 +08:00
9e96a30ea2 update unit test cases for garray/gparser 2019-08-01 17:31:48 +08:00
d188fbdf5a improve gyaml with gopkg.in/yaml.v3; update unit test cases for gfile/gyaml/gtime/garray 2019-08-01 17:12:58 +08:00
06c16bf560 remove thirdparty diectory, add go.mod for package dependences 2019-08-01 14:07:25 +08:00
29ea9e3237 travis updates 2019-08-01 11:42:51 +08:00
b01add2925 update project structure 2019-07-29 21:01:19 +08:00
a98ad9577b improve gjson/gparser/gcfg/gvar 2019-07-29 20:37:49 +08:00
ef8351151d merge master 2019-07-29 20:03:23 +08:00
f6bb3c848e Merge branch 'master' of https://github.com/gogf/gf 2019-07-29 19:52:24 +08:00
3fd4cbbbfd add MapStruct/MapStructDeep/MapStructs/MapStructsDeep functions for gconv 2019-07-29 19:52:05 +08:00
b102e0dbc5 add unit test cases for ghttp.RouterGroup 2019-07-28 17:58:43 +08:00
1c0e8f77c8 Merge branch 'develop' of https://github.com/gogf/gf into develop 2019-07-28 17:40:56 +08:00
bebcb70b14 merge master 2019-07-28 17:40:11 +08:00
165602ae0a improve default instance name handling 2019-07-28 17:37:13 +08:00
a36e00efeb improve ghttp for session storage with redis server 2019-07-28 13:10:34 +08:00
bd4d273e1c improve ghttp for session 2019-07-28 11:50:12 +08:00
216a928861 add IsEmpty for gvar; add CompareVersion for gstr 2019-07-27 15:36:52 +08:00
a157c3f940 add Map/Contains/Build functions for genv 2019-07-27 14:40:22 +08:00
5a23459b23 update unit test cases for gfile 2019-07-27 11:41:12 +08:00
538b282f43 improve internal/debug,glog,garray,gfile 2019-07-27 11:34:04 +08:00
86f51f1e4a improve gfile 2019-07-26 23:01:12 +08:00
622f76d5fb improve glog/gmd5/gcmd 2019-07-26 22:33:49 +08:00
65e06b12ae improve dir list for ghttp; add ISO8601/RFC822 functions for gtime 2019-07-25 23:25:30 +08:00
b714f7db69 add *Bytes functions for ghttp.Client; improve gcmd/gfile 2019-07-25 21:01:04 +08:00
1063922682 Merge branch 'master' of https://github.com/gogf/gf into develop 2019-07-24 22:49:48 +08:00
2c6168129a improve gfile/ghttp for file serving 2019-07-24 22:48:43 +08:00
45465c1bd1 version updates 2019-07-24 21:49:25 +08:00
8acecc88f9 improve internal/debug, gdb packages 2019-07-24 21:21:08 +08:00
575349929b improve gcompress 2019-07-24 15:58:56 +08:00
3913a89434 add Replace function for gfile 2019-07-24 15:29:10 +08:00
1bc8c9e3e2 add UnZipContent function for gcompress 2019-07-24 15:05:02 +08:00
b4a0cca9c4 add Name function for gfile; add ZipPath/UnZipFile functions for gcompress 2019-07-24 14:48:16 +08:00
78b13ef4e1 concurrent safety updates for unit test cases for internal/mutex,internal/rwmutex,grpool 2019-07-23 23:40:57 +08:00
a49df101cd change default value from unsafe to safe for garray/gmap/glist/gset/grong/gtree/gjson/gparser 2019-07-23 23:20:27 +08:00
7ff4a00063 Merge pull request #250 from hailaz/master 2019-07-23 21:51:17 +08:00
9f9cb097d9 修复gvalid.CheckStruct()的msgs覆盖tag的msg存在的bug。 2019-07-17 20:07:43 +08:00
f7c5d7fc7f gvalid补充修代码注释,移除错误的代码修改。 2019-07-15 21:14:46 +08:00
73235f1967 修复gvalid多条数据校验时,规则key没有对应校验数据导致校验异常的问题。 2019-07-13 15:20:41 +08:00
1ebc8092a6 Merge pull request #6 from gogf/master
sync master
2019-07-13 14:30:34 +08:00
88c43d1772 Merge pull request #5 from gogf/master
sync master
2019-07-13 12:35:33 +08:00
a0a8eb4700 TagMapField改回调用MapField 2019-07-13 11:47:20 +08:00
f24847576d 先移除新增的两个gvalid的test文件。 2019-07-13 10:52:02 +08:00
dfaf27e9e5 先还原对gvalid.Check()的修改。 2019-07-13 10:50:01 +08:00
32d5b28423 先还原对gvalid.Check()的修改。 2019-07-13 10:48:46 +08:00
0b8ca3313e 矫正gvalid.CheckStruct()字段别名记录的注释。
优化gvalid.CheckStruct()中属性的tag解析循环。
2019-07-13 10:47:52 +08:00
cdf92b64d6 Merge pull request #4 from gogf/master
sync master
2019-07-13 09:22:12 +08:00
cf745422f3 Fixed use cname in gvalid tag.
Added gvaild data type support for array, slice, map.
Added array, slice, map data test in gvaild unit test.
2019-07-11 15:41:10 +08:00
df8623c4e2 Merge pull request #3 from gogf/master
sync master
2019-07-10 10:30:21 +08:00
32fc6868aa Merge pull request #2 from gogf/master
sync master
2019-07-05 08:58:19 +08:00
d62c1dedf3 Merge pull request #1 from gogf/master
sync master
2019-07-03 11:03:54 +08:00
2066 changed files with 36866 additions and 549707 deletions

View File

@ -0,0 +1,46 @@
package main
import (
"fmt"
"github.com/gogf/gf/container/garray"
)
func main() {
// Create a int array, which is concurrent-unsafe in default.
a := garray.NewIntArray()
// Appending items.
for i := 0; i < 10; i++ {
a.Append(i)
}
// Get the length of the array.
fmt.Println(a.Len())
// Get the slice of the array.
fmt.Println(a.Slice())
// Get the item of specified index.
fmt.Println(a.Get(6))
// Insert after/before specified index.
a.InsertAfter(9, 11)
a.InsertBefore(10, 10)
fmt.Println(a.Slice())
a.Set(0, 100)
fmt.Println(a.Slice())
// Searching the item and returning the index.
fmt.Println(a.Search(5))
// Remove item of specified index.
a.Remove(0)
fmt.Println(a.Slice())
// Clearing the array.
fmt.Println(a.Slice())
a.Clear()
fmt.Println(a.Slice())
}

View File

@ -0,0 +1,22 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/garray"
)
func main() {
type Student struct {
Id int
Name string
Scores *garray.IntArray
}
s := Student{
Id: 1,
Name: "john",
Scores: garray.NewIntArrayFrom([]int{100, 99, 98}),
}
b, _ := json.Marshal(s)
fmt.Println(string(b))
}

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/garray"
)
func main() {
b := []byte(`{"Id":1,"Name":"john","Scores":[100,99,98]}`)
type Student struct {
Id int
Name string
Scores *garray.IntArray
}
s := Student{}
json.Unmarshal(b, &s)
fmt.Println(s)
}

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/garray"
"github.com/gogf/gf/container/garray"
)
func main() {

View File

@ -1,20 +1,23 @@
package main
import (
"github.com/gogf/gf/g"
"github.com/gogf/gf/g/container/garray"
"fmt"
"github.com/gogf/gf/container/garray"
)
func main() {
array := garray.NewSortedStringArray()
array.Add("1")
array.Add("2")
array.Add("3")
array.Add("4")
array.Add("5")
array.Add("6")
array.Add("7")
array.Add("8")
array := garray.NewSortedStrArray()
array.Add("9")
g.Dump(array.Slice())
array.Add("8")
array.Add("7")
array.Add("6")
array.Add("5")
array.Add("4")
array.Add("3")
array.Add("2")
array.Add("1")
fmt.Println(array.Slice())
// output:
// [1 2 3 4 5 6 7 8 9]
}

View File

@ -0,0 +1,22 @@
package main
import (
"fmt"
"github.com/gogf/gf/container/glist"
)
func main() {
l := glist.New()
// Push
l.PushBack(1)
l.PushBack(2)
e0 := l.PushFront(0)
// Insert
l.InsertBefore(e0, -1)
l.InsertAfter(e0, "a")
fmt.Println(l)
// Pop
fmt.Println(l.PopFront())
fmt.Println(l.PopBack())
fmt.Println(l)
}

View File

@ -0,0 +1,23 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/glist"
"github.com/gogf/gf/frame/g"
)
func main() {
type Student struct {
Id int
Name string
Scores *glist.List
}
s := Student{
Id: 1,
Name: "john",
Scores: glist.NewFrom(g.Slice{100, 99, 98}),
}
b, _ := json.Marshal(s)
fmt.Println(string(b))
}

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/glist"
)
func main() {
b := []byte(`{"Id":1,"Name":"john","Scores":[100,99,98]}`)
type Student struct {
Id int
Name string
Scores *glist.List
}
s := Student{}
json.Unmarshal(b, &s)
fmt.Println(s)
}

View File

@ -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()
// 设置键值对

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/container/gmap"
)
func main() {
m := gmap.New()
m.Sets(g.MapAnyAny{
"name": "john",
"score": 100,
})
b, _ := json.Marshal(m)
fmt.Println(string(b))
}

View File

@ -0,0 +1,14 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/gmap"
)
func main() {
m := gmap.Map{}
s := []byte(`{"name":"john","score":100}`)
json.Unmarshal(s, &m)
fmt.Println(m.Map())
}

View File

@ -0,0 +1,26 @@
package main
import (
"github.com/gogf/gf/container/gmap"
"github.com/gogf/gf/frame/g"
)
func main() {
m1 := gmap.New()
m1.Set("1", "1")
m2 := m1.Map()
m2["2"] = "2"
g.Dump(m1.Clone())
g.Dump(m2)
//output:
//{
// "1": "1"
//}
//
//{
// "1": "1",
// "2": "2"
//}
}

View File

@ -2,16 +2,17 @@ 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() {
array := g.Slice{2, 3, 1, 5, 4, 6, 8, 7, 9}
hashMap := gmap.New(true)
linkMap := gmap.NewLinkMap(true)
treeMap := gmap.NewTreeMap(gutil.ComparatorInt, true)
hashMap := gmap.New()
linkMap := gmap.NewListMap()
treeMap := gmap.NewTreeMap(gutil.ComparatorInt)
for _, v := range array {
hashMap.Set(v, v)
}

View File

@ -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() {

View File

@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gpool"
"time"
"github.com/gogf/gf/container/gpool"
)
func main() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gring"
"github.com/gogf/gf/container/gring"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gring"
"github.com/gogf/gf/container/gring"
)
type Player struct {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gset"
"github.com/gogf/gf/container/gset"
)
func main() {

View File

@ -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() {

View File

@ -0,0 +1,22 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/gset"
)
func main() {
type Student struct {
Id int
Name string
Scores *gset.IntSet
}
s := Student{
Id: 1,
Name: "john",
Scores: gset.NewIntSetFrom([]int{100, 99, 98}),
}
b, _ := json.Marshal(s)
fmt.Println(string(b))
}

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/gset"
)
func main() {
b := []byte(`{"Id":1,"Name":"john","Scores":[100,99,98]}`)
type Student struct {
Id int
Name string
Scores *gset.IntSet
}
s := Student{}
json.Unmarshal(b, &s)
fmt.Println(s)
}

View File

@ -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() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gtree"
"github.com/gogf/gf/container/gtree"
)
func main() {

View File

@ -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() {

View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gogf/gf/g/container/gtree"
"github.com/gogf/gf/container/gtree"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/container/gtype"
"github.com/gogf/gf/container/gtype"
)
func main() {

View File

@ -0,0 +1,22 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/gtype"
)
func main() {
type Student struct {
Id *gtype.Int
Name *gtype.String
Scores *gtype.Interface
}
s := Student{
Id: gtype.NewInt(1),
Name: gtype.NewString("john"),
Scores: gtype.NewInterface([]int{100, 99, 98}),
}
b, _ := json.Marshal(s)
fmt.Println(string(b))
}

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/container/gtype"
)
func main() {
b := []byte(`{"Id":1,"Name":"john","Scores":[100,99,98]}`)
type Student struct {
Id *gtype.Int
Name *gtype.String
Scores *gtype.Interface
}
s := Student{}
json.Unmarshal(b, &s)
fmt.Println(s)
}

View File

@ -0,0 +1,22 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/frame/g"
)
func main() {
type Student struct {
Id *g.Var
Name *g.Var
Scores *g.Var
}
s := Student{
Id: g.NewVar(1),
Name: g.NewVar("john"),
Scores: g.NewVar([]int{100, 99, 98}),
}
b, _ := json.Marshal(s)
fmt.Println(string(b))
}

View File

@ -0,0 +1,19 @@
package main
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/frame/g"
)
func main() {
b := []byte(`{"Id":1,"Name":"john","Scores":[100,99,98]}`)
type Student struct {
Id *g.Var
Name *g.Var
Scores *g.Var
}
s := Student{}
json.Unmarshal(b, &s)
fmt.Println(s)
}

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {
@ -29,8 +30,4 @@ func main() {
s := new(Score)
v.Struct(s)
fmt.Println(s)
// 只读接口
r := v.ReadOnly()
fmt.Println(r.String())
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
_ "github.com/denisenkom/go-mssqldb"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -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 {
@ -519,7 +519,6 @@ func getQueriedSqls() {
fmt.Println("Sql :", v.Sql)
fmt.Println("Args :", v.Args)
fmt.Println("Error:", v.Error)
fmt.Println("Func :", v.Func)
}
}

View File

@ -0,0 +1,6 @@
# MySQL数据库配置
[database]
debug = true
link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test"

View File

@ -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 {

View File

@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {
@ -17,4 +17,7 @@ func main() {
"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()
}

View File

@ -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() {

View File

@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -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() {

View File

@ -0,0 +1,24 @@
package main
import (
"github.com/gogf/gf/frame/g"
)
func main() {
// error!
r, err := g.DB().Table("user").Where(g.Map{
"or": g.Map{
"nickname": "jim",
"create_time > ": "2019-10-01",
},
"and": g.Map{
"nickname": "tom",
"create_time > ": "2019-10-01",
},
}).All()
if err != nil {
panic(err)
}
g.Dump(r)
}

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -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() {

View File

@ -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() {

View File

@ -1,7 +1,7 @@
package main
import (
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"time"
"github.com/gogf/gf/frame/g"
)
func main() {

View 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)
}

View File

@ -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() {

View File

@ -1,15 +1,16 @@
package main
import (
"github.com/gogf/gf/g"
"time"
"github.com/gogf/gf/frame/g"
)
func main() {
db := g.DB()
db.SetMaxIdleConns(10)
db.SetMaxOpenConns(10)
db.SetConnMaxLifetime(10)
db.SetMaxIdleConnCount(10)
db.SetMaxOpenConnCount(10)
db.SetMaxConnLifetime(time.Minute)
// 开启调试模式以便于记录所有执行的SQL
db.SetDebug(true)

View File

@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View 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)
}
}

View 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)
}
}
}

View 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)
}

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -0,0 +1,24 @@
package main
import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
)
func main() {
db := g.DB()
//db.SetDebug(true)
type User struct {
Id int
Name *gtime.Time
}
user := new(User)
e := db.Table("test").Where("id", 10000).Struct(user)
if e != nil {
panic(e)
}
g.Dump(user)
}

View File

@ -0,0 +1,34 @@
package main
import (
"github.com/gogf/gf/frame/g"
"time"
)
func test1() {
db := g.DB()
db.SetDebug(true)
time.Sleep(1 * time.Minute)
r, e := db.Table("test").Where("id", 10000).Count()
if e != nil {
panic(e)
}
g.Dump(r)
}
func test2() {
db := g.DB()
db.SetDebug(true)
dao := db.Table("test").Safe()
time.Sleep(1 * time.Minute)
r, e := dao.Where("id", 10000).Count()
if e != nil {
panic(e)
}
g.Dump(r)
}
func main() {
test1()
test2()
}

View File

@ -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 {
@ -520,7 +520,6 @@ func getQueriedSqls() {
fmt.Println("Sql :", v.Sql)
fmt.Println("Args :", v.Args)
fmt.Println("Error:", v.Error)
fmt.Println("Func :", v.Func)
}
}

View File

@ -0,0 +1,47 @@
package main
import (
"fmt"
"github.com/gogf/gf/database/gdb"
"github.com/gogf/gf/frame/g"
_ "github.com/mattn/go-sqlite3"
)
func main() {
gdb.SetConfig(gdb.Config{
"default": gdb.ConfigGroup{
gdb.ConfigNode{
Name: "/tmp/my.db",
Type: "sqlite",
},
},
})
db := g.DB()
if db == nil {
panic("db create failed")
}
// 创建表
sql := `CREATE TABLE user (
uid INT PRIMARY KEY NOT NULL,
name VARCHAR(30) NOT NULL
);`
if _, err := db.Exec(sql); err != nil {
fmt.Println(err)
}
// 写入数据
result, err := db.Table("user").Data(g.Map{"uid": 1, "name": "john"}).Save()
if err == nil {
fmt.Println(result.RowsAffected())
} else {
fmt.Println(err)
}
// 删除表
sql = `DROP TABLE user;`
if _, err := db.Exec(sql); err != nil {
fmt.Println(err)
}
}

View File

@ -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链接池

View File

@ -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方法

View File

@ -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() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -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() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View File

@ -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() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {

View 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())
}

View File

@ -1,8 +1,9 @@
package main
package gbase64
import (
"fmt"
"github.com/gogf/gf/g/encoding/gbase64"
"github.com/gogf/gf/encoding/gbase64"
)
func main() {

View File

@ -2,32 +2,26 @@ 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() {
// 使用gbinary.Encoded对基本数据类型进行二进制打包
if buffer, err := gbinary.Encode(18, 300, 1.01); err != nil {
glog.Error(err)
} else {
fmt.Println(buffer)
}
fmt.Println(gbinary.Encode(18, 300, 1.01))
// 使用gbinary.Decode对整形二进制解包注意第二个及其后参数为字长确定的整形变量的指针地址字长确定的类型
// 例如int8/16/32/64、uint8/16/32/64、float32/64
// 这里的1.01默认为float64类型(64位系统下)
if buffer, err := gbinary.Encode(18, 300, 1.01); err != nil {
buffer := gbinary.Encode(18, 300, 1.01)
var i1 int8
var i2 int16
var f3 float64
if err := gbinary.Decode(buffer, &i1, &i2, &f3); err != nil {
glog.Error(err)
} else {
var i1 int8
var i2 int16
var f3 float64
if err := gbinary.Decode(buffer, &i1, &i2, &f3); err != nil {
glog.Error(err)
} else {
fmt.Println(i1, i2, f3)
}
fmt.Println(i1, i2, f3)
}
// 编码/解析 int自动识别变量长度

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/encoding/gbinary"
"github.com/gogf/gf/encoding/gbinary"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/encoding/gbinary"
"github.com/gogf/gf/encoding/gbinary"
)
func main() {

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g"
"github.com/gogf/gf/frame/g"
)
func main() {
@ -14,6 +15,6 @@ func main() {
}
redisCfg := new(RedisConfig)
fmt.Println(g.Config().GetToStruct("redis", redisCfg))
fmt.Println(g.Config().GetStruct("redis", redisCfg))
fmt.Println(redisCfg)
}

View File

@ -2,7 +2,8 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/encoding/gcharset"
"github.com/gogf/gf/encoding/gcharset"
)
func main() {
@ -14,4 +15,6 @@ func main() {
panic(err)
}
fmt.Println(str)
// output:
// 花间一壶酒,独酌无相亲。
}

View 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)
}

View 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)
}

View 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)
}

View File

@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/encoding/ghash"
"strconv"
"github.com/gogf/gf/encoding/ghash"
)
func main() {

View 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)
}

View File

@ -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() {

View 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)
}

View 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)
}

View File

@ -0,0 +1,19 @@
package main
import (
"fmt"
"github.com/gogf/gf/encoding/gjson"
)
func main() {
s := `
{"apiVersion":"v1","kind":"Service","metadata":{"labels":{"name":"http-daemon"},"name":"http-daemon","namespace":"default"},"spec":{"ports":[{"name":"http-daemon","port":8080,"protocol":"TCP","targetPort":9212}],"selector":{"app":"http-daemon","version":"v0930-082326"}}}
`
js, err := gjson.DecodeToJson(s)
if err != nil {
panic(err)
}
//g.Dump(js.ToMap())
y, _ := js.ToYamlString()
fmt.Println(y)
}

View 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: ""

View File

@ -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() {
@ -18,7 +19,7 @@ func getWithPattern1() {
}
}`
if p, e := gparser.LoadContent([]byte(data), "json"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
fmt.Println("John Score:", p.GetFloat32("users.list.1.score"))
@ -35,7 +36,7 @@ func getWithPattern2() {
<body>Don't forget me this weekend!</body>
</note>`
if p, e := gparser.LoadContent([]byte(data), "xml"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
fmt.Println("Heading:", p.GetString("note.heading"))
@ -51,7 +52,7 @@ func multiDots1() {
},
"users.count" : 101
}`
if p, e := gparser.LoadContent([]byte(data), "json"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
fmt.Println("Users Count:", p.Get("users.count"))
@ -69,7 +70,7 @@ func multiDots2() {
"count.type1" : 100
}
}`
if p, e := gparser.LoadContent([]byte(data), "json"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
fmt.Println("Users Count:", p.Get("users.count.type1"))
@ -87,7 +88,7 @@ func set1() {
<list><title>gf article2</title><content>gf content2</content></list>
<list><title>gf article3</title><content>gf content3</content></list>
</article>`
if p, e := gparser.LoadContent([]byte(data), "xml"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
p.Set("article.list.0", nil)
@ -104,7 +105,7 @@ func set2() {
"count" : 100
}
}`
if p, e := gparser.LoadContent([]byte(data), "json"); e != nil {
if p, e := gparser.LoadContent([]byte(data)); e != nil {
glog.Error(e)
} else {
p.Set("users.count", 1)
@ -115,7 +116,7 @@ func set2() {
}
func makeXml1() {
p := gparser.New()
p := gparser.New(nil)
p.Set("name", "john")
p.Set("age", 18)
p.Set("scores", map[string]int{
@ -132,7 +133,7 @@ func makeJson1() {
Id int `json:"id"`
Price float32 `json:"price"`
}
p := gparser.New()
p := gparser.New(nil)
p.Set("orders.list.0", Order{1, 100})
p.Set("orders.list.1", Order{2, 666})
p.Set("orders.list.2", Order{3, 999.99})

View File

@ -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"?>

View 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)
}

View 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)
}

View File

@ -4,7 +4,7 @@ import (
"errors"
"fmt"
"github.com/gogf/gf/g/errors/gerror"
"github.com/gogf/gf/errors/gerror"
)
func Error1() error {

View File

@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/gogf/gf/g/errors/gerror"
"github.com/gogf/gf/errors/gerror"
)
func OpenFile() error {

Some files were not shown because too many files have changed in this diff Show More