mirror of
https://gitee.com/johng/gf
synced 2026-06-07 18:26:02 +08:00
Compare commits
1856 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59d6830ab1 | |||
| 8779a3f211 | |||
| c10149baa0 | |||
| 4f87668780 | |||
| 63f33d1d8c | |||
| 734aa5a6fe | |||
| 371aef224d | |||
| 362e380ada | |||
| e995bd8c9a | |||
| 81b211dd1a | |||
| 0515fc94cb | |||
| 46ee070f0a | |||
| b17e3a6804 | |||
| 8e6018cfff | |||
| c08739b5a3 | |||
| 385a503d31 | |||
| ef286b0c15 | |||
| 53aba2d4b8 | |||
| f22da4ba3a | |||
| 23c2f12672 | |||
| 7fd53673ce | |||
| 2ea1d2c7b2 | |||
| 90d751f98d | |||
| 25a91c732c | |||
| 01995f5501 | |||
| 68abb3cf3d | |||
| 77cc323d0e | |||
| c7a9c03495 | |||
| f7850e3ed3 | |||
| 82125416a2 | |||
| 2c1e2155e3 | |||
| 2d30a53c3a | |||
| ccceeae29c | |||
| f22b98456f | |||
| e7f1bd692b | |||
| f82f7ab199 | |||
| 4d33b527b6 | |||
| 7bcc596308 | |||
| be2d4b080e | |||
| c96e5f5a9e | |||
| 3c23766674 | |||
| 718089fc11 | |||
| 8ab44dcb44 | |||
| 992522342c | |||
| 040898cdc3 | |||
| 343126ef22 | |||
| 05760d1eac | |||
| c10f73f1f7 | |||
| 7e0fa8e0cd | |||
| 6fe6218505 | |||
| 6059782de8 | |||
| 4844eea0ab | |||
| 8ecd62d3de | |||
| 4c610b4f58 | |||
| 1932c4ec44 | |||
| bd2e51ddca | |||
| ddcb7121c1 | |||
| f1f575fd5c | |||
| 99adb7cdc4 | |||
| 6b7ea97777 | |||
| 495b5758ec | |||
| ba56eb87b1 | |||
| 4258a3bbc9 | |||
| 4912331ddc | |||
| e87b7ecf5d | |||
| 23bce7bde6 | |||
| 926b664615 | |||
| fa8257c85b | |||
| abb9c88c23 | |||
| f89976cad5 | |||
| 0389778725 | |||
| 3c36285126 | |||
| 75054ee109 | |||
| 8447b1a42b | |||
| e5265a1c46 | |||
| 6e8ef8d0b0 | |||
| 75c081afc9 | |||
| 060fd9eaba | |||
| 63e5a60344 | |||
| 75dc1d82c1 | |||
| a5e048eb5f | |||
| 65bc1d5eb8 | |||
| bfa64705b5 | |||
| 17aea8d7d4 | |||
| a6a01fd7f2 | |||
| 41a9e91b4c | |||
| e2c1e11f95 | |||
| c2966817ce | |||
| 16958413bb | |||
| c0a0913d4b | |||
| 6d47810782 | |||
| 7a9ea2e546 | |||
| 7881b2dee4 | |||
| 5f223ef049 | |||
| e57942b374 | |||
| f18e6f078c | |||
| f667cbc2a2 | |||
| 07e65c14a9 | |||
| 0b6d04485e | |||
| 36401a063d | |||
| 849e7370d1 | |||
| f01dca0895 | |||
| 55137b2aa3 | |||
| 22540921b3 | |||
| 6174097a07 | |||
| 52de11b1fe | |||
| 5a646179ad | |||
| 33ae93e050 | |||
| f3d859159d | |||
| 4fb01e68f7 | |||
| 2812a247aa | |||
| 2b46e765c4 | |||
| c7f911cae2 | |||
| 9f0548c03d | |||
| c578df06a3 | |||
| 8ed3cf9c97 | |||
| 2438f565e9 | |||
| 8230c72ec6 | |||
| d716037caa | |||
| 855a4ddb2c | |||
| 74be9fac18 | |||
| e9fba5a166 | |||
| 0a92df691b | |||
| e513cd10ed | |||
| b702d98700 | |||
| 99f1d9d0ed | |||
| 707b08c585 | |||
| f44c19868c | |||
| 13ab139afc | |||
| cacb2f142b | |||
| 11f0317e92 | |||
| 9a667c8803 | |||
| c1cce17934 | |||
| 5a92d7de0d | |||
| 53bf378868 | |||
| cd7c45c00c | |||
| f13a5ad82e | |||
| 2e9be609c8 | |||
| 2f2f6e1ffe | |||
| f3bd2b67f7 | |||
| 645cecdffb | |||
| 22e9965629 | |||
| 24ea9f9245 | |||
| 9dbde6e8f1 | |||
| fe0b34544d | |||
| 5e489d59b4 | |||
| 61f49574a9 | |||
| 2fabcb62a8 | |||
| 3bc3b652c1 | |||
| 042a6f12f5 | |||
| 5acce82e63 | |||
| 4732bf46ad | |||
| 5bed5a1532 | |||
| 5b7576430f | |||
| 356f4cd701 | |||
| c444630d1e | |||
| 8e40cded42 | |||
| 0e52d467d3 | |||
| 6665d62e7e | |||
| 5bdf1a71b8 | |||
| a34ca0ff4b | |||
| 7f0163d958 | |||
| 31f19b0eee | |||
| 93d0760898 | |||
| 4863e7a6ae | |||
| a161b44cc7 | |||
| 7072244420 | |||
| f68b66e606 | |||
| 4e7c6c1fb4 | |||
| d8a7e36478 | |||
| 8971ad8445 | |||
| 270af8accb | |||
| b0ef63fc9d | |||
| 6e1f8c3cfc | |||
| e58d7e8dda | |||
| 3a3384cf06 | |||
| ef2a9f6fd1 | |||
| 63f756f731 | |||
| bb1c27c36a | |||
| 87cd0703c0 | |||
| 6317d9de53 | |||
| 7acf16fdba | |||
| a52b454d3e | |||
| 816e075c52 | |||
| 9882b361a8 | |||
| 4415dcf1c1 | |||
| 42fd583bfd | |||
| c70bc7c96a | |||
| 02bd780a33 | |||
| 24a2192ce2 | |||
| d8ef8a1f5d | |||
| 745a913cfb | |||
| 13dba407a2 | |||
| 34e7c5f809 | |||
| d570624caa | |||
| f18312419b | |||
| 89f869dd44 | |||
| 20b64507b1 | |||
| 7443246e05 | |||
| f9e7823c14 | |||
| 52943b283c | |||
| 36403fdc08 | |||
| 0317f6812e | |||
| 5169137069 | |||
| 7d9bccf912 | |||
| 14f56ea18f | |||
| 1736d271d2 | |||
| 19755ad233 | |||
| cfdd043e4e | |||
| 78917ed5cb | |||
| 88684ca00a | |||
| 784983806a | |||
| cdb3b94e22 | |||
| 83dcc4a5e0 | |||
| a6c0b281a3 | |||
| 3120f24553 | |||
| ac9be6134b | |||
| 4c1b4f7858 | |||
| 1e45bf93d8 | |||
| e8dd3979b6 | |||
| 374ee4c0ea | |||
| 95411aff77 | |||
| 1999ef95c1 | |||
| b15075fdfe | |||
| 4d2b244319 | |||
| 4c3af63076 | |||
| 91bbff6ced | |||
| 26aab44ec8 | |||
| 2e10ce421b | |||
| 8eda69b11e | |||
| 7d7b242968 | |||
| 202419202f | |||
| 55078beed1 | |||
| d9f4e6eaa6 | |||
| 2ba0913bea | |||
| 8f2dcf21ff | |||
| 01b06e0745 | |||
| 665b5960c8 | |||
| eb6a7a4728 | |||
| 7df53ff55e | |||
| 8021f39710 | |||
| f2af08270b | |||
| c2f028848c | |||
| d9c7224861 | |||
| f59a1ada88 | |||
| 705ab1d33f | |||
| c07c4d7217 | |||
| b867b2a0bc | |||
| 872d674182 | |||
| 4682abafdf | |||
| b7d194cf52 | |||
| edf2366296 | |||
| 22af5be71f | |||
| f662ff8051 | |||
| 8c51121b3b | |||
| e9a0805801 | |||
| afadbc6621 | |||
| ca546fc30b | |||
| 7c7c168c3d | |||
| 16f0bb96db | |||
| 33a899d32e | |||
| f3a208f02f | |||
| 81fd3d06bb | |||
| 9227139cf8 | |||
| f2190e50b2 | |||
| c4537b4753 | |||
| 167d58490b | |||
| d36aceb9f1 | |||
| eb31922124 | |||
| bec9f5a847 | |||
| 506552c3a9 | |||
| 2bacc77224 | |||
| bc53f265af | |||
| 344f232c36 | |||
| 27b677b0c0 | |||
| a5a0e381bd | |||
| d528d7f5ab | |||
| 821c71bd8d | |||
| 604a10400d | |||
| 9219471f67 | |||
| fe5d2e5685 | |||
| 0a89daa513 | |||
| d6e6ddf996 | |||
| 5dbda8aedc | |||
| 134e4cf28f | |||
| 56a85abef7 | |||
| 80c6ceaf26 | |||
| a10f428715 | |||
| 597f7468e9 | |||
| 5db8851213 | |||
| 1d53d760d8 | |||
| 922e720d63 | |||
| 50018773b7 | |||
| df99036d41 | |||
| ae0fa888f0 | |||
| 18892fb66d | |||
| 5f2be10563 | |||
| a5a88222a6 | |||
| 4facdd5c9e | |||
| 76bc9bd385 | |||
| 364452f3bb | |||
| 4996755f11 | |||
| e33230a88f | |||
| 951ce46932 | |||
| 795c7395e6 | |||
| 27cf47bcd3 | |||
| 58a25c6f61 | |||
| 2d754f80b1 | |||
| f4e8fbe767 | |||
| 458318d374 | |||
| e3f54e1353 | |||
| 4374996073 | |||
| 87295ef1fe | |||
| 81d4082b6a | |||
| d7e19bc3f3 | |||
| 34ef0ea792 | |||
| 2804834540 | |||
| add7dd5a45 | |||
| e40894ca45 | |||
| 28825f5395 | |||
| 6ca5141020 | |||
| fe4f8e1810 | |||
| 671157cb70 | |||
| f775479c3f | |||
| 64bb72842e | |||
| e1d4ba9d23 | |||
| a1edd83add | |||
| f7d6883405 | |||
| 8448a70646 | |||
| 4018bfa899 | |||
| 3cc9ce74e1 | |||
| eac60d845f | |||
| 835c045c92 | |||
| be15f85eae | |||
| 3e27ea0259 | |||
| 6abe660287 | |||
| a06ca31530 | |||
| 890865251b | |||
| 6af90cafee | |||
| 2e2363bb41 | |||
| 108ced2b0b | |||
| fcba650348 | |||
| 1b8a082942 | |||
| 40570cdb03 | |||
| 10451864e6 | |||
| 55e2646367 | |||
| c88839edb1 | |||
| 2a2cfc289c | |||
| 8bbeb186c2 | |||
| be4bf39719 | |||
| 459c69839a | |||
| a5407e57d9 | |||
| 5c749e7762 | |||
| b3fafc64f8 | |||
| c7b0763ab0 | |||
| 0cfdf60de5 | |||
| 096bff791d | |||
| 0cce858641 | |||
| bb45d8d578 | |||
| 7e43aa6b9d | |||
| 4ee7c82bf1 | |||
| 85caa40a3d | |||
| f4654bf446 | |||
| 94ed0bf9c9 | |||
| 22e3705d3e | |||
| 9b1cc6e9c7 | |||
| 9429c8ff83 | |||
| 056c6d4688 | |||
| 382356bc8d | |||
| 1deb3510f0 | |||
| dd7ae1b07a | |||
| 04a8755162 | |||
| 682f99a763 | |||
| 61282d6dab | |||
| ad540f7c25 | |||
| a4f191c1c6 | |||
| 43531c2680 | |||
| 635f5d36fd | |||
| 1becc4932c | |||
| e36dd06f22 | |||
| 8f2c62d444 | |||
| 21efde1a38 | |||
| d8b6466ed0 | |||
| d7b0228e9e | |||
| 9da1277b47 | |||
| a3fd0c9a4a | |||
| ad7375b44b | |||
| 05120b585d | |||
| 9e32d74c8c | |||
| 0e62510c6f | |||
| c492de4fa8 | |||
| 6308380541 | |||
| 2609db1aec | |||
| 6c54e73dbd | |||
| 21abe62633 | |||
| e30b2b0732 | |||
| dcb74ee9df | |||
| 82bf21e831 | |||
| 66355354fc | |||
| 4204125dce | |||
| e6aa9d3a46 | |||
| 9416cd1274 | |||
| 8b5ab846b2 | |||
| a15b93be90 | |||
| 38ee5f7d53 | |||
| 6f9bbbf416 | |||
| 143bc3d8e3 | |||
| ea75b1a936 | |||
| 0dde8c735e | |||
| 1ab7f00b91 | |||
| 3ef42bfbf0 | |||
| 05fec23457 | |||
| 7225e49aa0 | |||
| 14e9deb254 | |||
| f9569b387f | |||
| a0722ed51f | |||
| e9ace9b17a | |||
| 4791d10761 | |||
| c686b1c080 | |||
| 056d6ebbd9 | |||
| baa2cb68de | |||
| e4909b318b | |||
| f1b7cb37c6 | |||
| 734728fa9c | |||
| b373ace065 | |||
| bc7b5c8626 | |||
| f2b45622d6 | |||
| 77cb219057 | |||
| cf34d7bd56 | |||
| 5adc9be0d9 | |||
| 58b2efc900 | |||
| 28326606f5 | |||
| 91c98bbb60 | |||
| 63cd1128a7 | |||
| c0236d7dfa | |||
| d4051df5b6 | |||
| 88045417ff | |||
| 500efb5601 | |||
| 97fe8235da | |||
| e1164e935b | |||
| b26330aee1 | |||
| 2b083709b5 | |||
| 0ac45dc379 | |||
| 650916c22a | |||
| 2804183325 | |||
| 2dc2610621 | |||
| 1736e71e6b | |||
| 69ee5375b9 | |||
| 3ac0a66887 | |||
| 20e873a1fc | |||
| 142484d89c | |||
| 76a9f4ca14 | |||
| c4e5679d5c | |||
| b08d7c3c38 | |||
| 5092d8e6c5 | |||
| 74d625ff97 | |||
| f1119e28e8 | |||
| 3082c7f761 | |||
| 5f36614dd7 | |||
| 1dcc7a4887 | |||
| 41e9d35487 | |||
| 977c8b7ee3 | |||
| 939e6244ee | |||
| e764b2393d | |||
| 6384e75ed9 | |||
| 195cae6577 | |||
| c8cf46a5a7 | |||
| eba97277b2 | |||
| 4e19fbc5fb | |||
| 494b5bbae2 | |||
| 987ce709e5 | |||
| 35ad4d869f | |||
| 39d654e3f2 | |||
| 7fe9c641f4 | |||
| ee1414c010 | |||
| 8eb1b685a5 | |||
| 46768d6f91 | |||
| bb6fed3dc2 | |||
| 47e74d27bf | |||
| b830f9b96d | |||
| c85162a8a0 | |||
| ef4e128af7 | |||
| cce8ac5118 | |||
| cb7c3a9fa4 | |||
| b0f859cc91 | |||
| 6d4da529ee | |||
| 6c7e536eeb | |||
| 36c2648be8 | |||
| 419b58452f | |||
| b1835ea4e8 | |||
| a876b6133d | |||
| 03ff358da8 | |||
| 037f74c549 | |||
| 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 | |||
| 8669057681 | |||
| b439aedce5 | |||
| 2504e405a7 | |||
| 6426409bf9 | |||
| 9cf4ea5c91 | |||
| 86343abcf8 | |||
| d0fe2d2f75 | |||
| 49ef4fd266 | |||
| 929a57ceb8 | |||
| c6f94ed95a | |||
| 949ac459fc | |||
| 32fc6868aa | |||
| 82394cd70e | |||
| 4670a5d2e2 | |||
| 273d992493 | |||
| 1c71340719 | |||
| ed61c2ee22 | |||
| 363dede57c | |||
| b29c6add47 | |||
| 8d01e565c5 | |||
| 47e0fb95d5 | |||
| 23d346b291 | |||
| 105cdf6fe6 | |||
| 5135264d56 | |||
| c3ff1a3db3 | |||
| d62c1dedf3 | |||
| bd105a188f | |||
| 09affd3981 | |||
| 8e7e18e22d | |||
| e03fd80fd4 | |||
| adc3201dcf | |||
| 3a681e5b1a | |||
| c90ed0d424 | |||
| 418cbb420b | |||
| c948f0c287 | |||
| 285b45d19d | |||
| 783f1c8457 | |||
| daa7f12994 | |||
| e63e989d41 | |||
| 31921905a9 | |||
| 5572ab858e | |||
| 961ca0879d | |||
| 5d464494b6 | |||
| 4ca2513d00 | |||
| 15d69ed950 | |||
| 39bd2616c4 | |||
| 6302789c41 | |||
| 0ff31012c8 | |||
| 5c7b25c960 | |||
| 10102f2db9 | |||
| 6f5b5e4dc2 | |||
| 007c8a7b64 | |||
| 009ce9063e | |||
| 58a405bfa8 | |||
| 42214f17fc | |||
| b5f117e932 | |||
| b0f158047c | |||
| d5f7ca634d | |||
| aa6110c619 | |||
| a9660fe9fa | |||
| 0801245871 | |||
| 278fd3515f | |||
| 56588f3f7f | |||
| a5d01cb547 | |||
| fabf5d1ad5 | |||
| ebae3a4929 | |||
| 8e6640ed79 | |||
| e4c42bde89 | |||
| f7515edde9 | |||
| 2b0da75412 | |||
| 04c422c3af | |||
| 339ca74ff4 | |||
| 741a13379a | |||
| da907f35bd | |||
| 133531b6a0 | |||
| 5fa0f8dd7e | |||
| 7247413a48 | |||
| 591158adc5 | |||
| 5d83383105 | |||
| 5ad809f49e | |||
| 56a62bb4c2 | |||
| afb4a233be | |||
| c0aebe023c | |||
| 055c6a668e | |||
| 735c5fc7ed | |||
| c066fff971 | |||
| 89373ebcd6 | |||
| 51cf232691 | |||
| 3bfff2347f | |||
| 7d83604540 | |||
| f25571a0a9 | |||
| 05c7ba5f29 | |||
| dcf7772589 | |||
| 3806f9db07 | |||
| 0f14002b05 | |||
| 1bf53d8b89 | |||
| 8eb10a58ad | |||
| 9985378062 | |||
| 38ad5d457b | |||
| ebed433dde | |||
| 2b02f7e210 | |||
| 1434800982 | |||
| 327e33b827 | |||
| d2a053c1d7 | |||
| abe14e049a | |||
| 4b9db0c794 | |||
| b118cd8f27 | |||
| 83669964f5 | |||
| 9248fd6b28 | |||
| bb935967ac | |||
| b7e0f1f983 | |||
| 6ee6c007c5 | |||
| 9a507b54d7 | |||
| c88f516759 | |||
| 912b743a1e | |||
| d546424f18 | |||
| fe179fff42 | |||
| adf2ddb510 | |||
| f30c9020fa | |||
| 1b3073f3f9 | |||
| 615161ac9d | |||
| 02e06e7c6e | |||
| d15268eb22 | |||
| e48415d932 | |||
| e5fa341f39 | |||
| 234d734981 | |||
| d771ed9209 | |||
| 37d72cb8b3 | |||
| 1154f9601b | |||
| 322513f99b | |||
| 6e7ac60d4d | |||
| 405840607f | |||
| 8417e7ef65 | |||
| ac2fe44d8e | |||
| 3030d7f032 | |||
| dcf7138694 | |||
| 97df154b78 | |||
| d74034e08e | |||
| 674590e247 | |||
| d41cc7c3b6 | |||
| ab48800401 | |||
| ea456c5faa | |||
| 83d1442781 | |||
| 5888b0e06a | |||
| 3120d0bd7a | |||
| a7dcc2c9c6 | |||
| 17898cc747 | |||
| 7bebf062be | |||
| 048c3d5025 | |||
| 0adcdc6b4a | |||
| 19d7ad734b | |||
| 6c657dff37 | |||
| 78ccbeac3b | |||
| 2a0eae8975 | |||
| 28d25e7812 | |||
| fe795d49f3 | |||
| 9fad898ee3 | |||
| 9a42142ce7 | |||
| 9db8ed2dfc | |||
| 619a539f2e | |||
| ae8eb4a1f1 | |||
| 9a469e64da | |||
| f7d1613d62 | |||
| 80655bce50 | |||
| b3b0ba775c | |||
| 4713739d1a | |||
| 53b5de330e | |||
| fd4843c3a1 | |||
| 97d2b9e1f9 | |||
| 5896dadaad | |||
| 0ab60cb770 | |||
| 5b71e92776 | |||
| 211678c7d3 | |||
| d25793ed03 | |||
| 98cae011a5 | |||
| 59ae6f9c10 | |||
| 474d1669d9 | |||
| 563a1408ea | |||
| 168c08a6f6 | |||
| 82783072ef | |||
| 11972ef96c | |||
| 468ba21283 | |||
| 78b0cae892 | |||
| 866482a8e8 | |||
| c342310389 | |||
| 0eb028f0b5 | |||
| 4ffe4f2262 | |||
| 677549ec15 | |||
| 68d8e25bc4 | |||
| 4f007fdd44 | |||
| 54392941f3 | |||
| ebdad47f2d | |||
| cb4e36f591 | |||
| cd30efaaa1 | |||
| 7c234e0437 | |||
| d973c5d5c7 | |||
| a7f15a4e00 | |||
| 6b5484bf55 | |||
| ab38b709b2 | |||
| 4118038198 | |||
| 142154c0df | |||
| 07ae90d64d | |||
| 8a69fd09fc | |||
| c02f502bd8 | |||
| d5d6b8c303 | |||
| 5c592afebe | |||
| 8402a2b710 | |||
| fe152dfa63 | |||
| e695983d4d | |||
| a5ab2ba332 | |||
| c6e5a52104 | |||
| 1b4a879eda | |||
| c5aa493d24 | |||
| a88363e34c | |||
| 0f1261d0e3 | |||
| c41d11df9f | |||
| 1e680c7a8b | |||
| e981143ead | |||
| 3e2d5e0bdb | |||
| 1f19ed71aa | |||
| 4de6881c89 | |||
| 5baa82da8f | |||
| 48f610a216 | |||
| e4e58791a6 | |||
| 46c42ec249 | |||
| d068c1418e | |||
| 41db3a32f4 | |||
| b3a00becf3 | |||
| d1d8cd8482 | |||
| 1228907d59 | |||
| 57b54414d6 | |||
| 548a0c47af | |||
| 4934564b7b | |||
| 7348d14fef | |||
| 9cddb7ed9a | |||
| 8c84de3f73 | |||
| 96529a4c1c | |||
| c7a729fe06 | |||
| 23d404f681 | |||
| 887aeee2d4 | |||
| 622dbfda31 | |||
| 80cf3e833b | |||
| d305d25935 | |||
| 81502cfb6d | |||
| 5950a3fcc3 | |||
| 55f5e6d7aa | |||
| e2070e785c | |||
| 905d5abed6 | |||
| 211e06d04d | |||
| 7aaf9e9228 | |||
| a901e7177c | |||
| afc2bcfb28 | |||
| 8da204fbd8 | |||
| 5aa3212fe1 | |||
| 17d49510c4 | |||
| 4af8ae1470 | |||
| 3a5c660693 | |||
| 9e65100a06 | |||
| 399e47c548 | |||
| abdf8e696c | |||
| 4a2e217625 | |||
| 52d0280137 | |||
| 5be9765eb7 | |||
| cdb9488752 | |||
| 0388113870 | |||
| c6dfb4d4f8 | |||
| 4a40b58b63 | |||
| 407068a0bf | |||
| 165330ec68 | |||
| 6e7d08fbfb | |||
| 1ae77f56e5 | |||
| fccac04980 | |||
| 469f9c7ce5 | |||
| d6d37248f6 | |||
| cb1084b770 | |||
| e6d4459992 | |||
| 1afb5a4bc5 | |||
| c124f172b2 | |||
| dbd4a7c1d4 | |||
| a4d30ef206 | |||
| 0a616173ef | |||
| 597f210f85 | |||
| 24bd83feb0 | |||
| 3855786905 | |||
| 1f670a1ab2 | |||
| d97fda794c | |||
| c034d25299 | |||
| dd6152fe8a | |||
| 485fe572ff | |||
| 15bf5d9a4d | |||
| 08aa7c4e4c | |||
| 442c658be0 | |||
| 5aa8ce1c6b | |||
| ad8ece68c6 | |||
| 74525ba8f7 | |||
| 46d46afaaf | |||
| 13eb1150a5 | |||
| f98db6d21c | |||
| c695dfd92e | |||
| ffd78d76e1 | |||
| e479c41667 | |||
| 9f8c481992 | |||
| 3320d12994 | |||
| be6f522cf3 | |||
| b0b6871bbb | |||
| 59ae6217cd | |||
| 334cd7ad51 | |||
| 501c3680d9 | |||
| ebcc81c1ee | |||
| 6814372a89 | |||
| d5d14b7efc | |||
| 3a72686774 | |||
| aa73c5ed53 | |||
| cc0a385c22 | |||
| 0b8c9713e6 | |||
| e400a94ffb | |||
| 136ad3b0b5 | |||
| f9826104d8 | |||
| c0c97b76fb | |||
| a908e4d4b1 | |||
| e5c255200c | |||
| 00db4f5ed9 | |||
| 29ead3ff3e | |||
| 055074246e | |||
| 4bbe51fb4b | |||
| 841224372b | |||
| d1f0fa1a47 | |||
| 6fecf8bb01 | |||
| 6d44f02a38 | |||
| 1458e486d7 | |||
| dc29822e69 | |||
| dae7722da1 | |||
| 16d978dc58 | |||
| 5d3c154b45 | |||
| 00a8ef63b6 | |||
| 6ac437a3a5 | |||
| 33b24eba01 | |||
| 3a99c6e5f5 | |||
| 4c5d2839bd | |||
| 85b104bafa | |||
| 74e5d03a78 | |||
| cc43324ede | |||
| e4f9e1000d | |||
| 62829b0698 | |||
| 2551e990cb | |||
| 45c34319b5 | |||
| 75dcc566b3 | |||
| 4f1047e853 | |||
| 79f765c961 | |||
| eead2fad2c | |||
| 455c9e09ab | |||
| 4665c3565c | |||
| 7456b4b4ad | |||
| 32a6454065 | |||
| c52640c672 | |||
| d62ef17290 | |||
| 216af6a662 | |||
| 35d860427e | |||
| 9206574bae | |||
| 9c6f54131f | |||
| d67b95c593 | |||
| 2bf2f1b822 | |||
| 9ad94eccad | |||
| 6e8a900f25 | |||
| d9aa9e4480 | |||
| fe74818a37 | |||
| 7335126064 | |||
| 945dd71251 | |||
| 652aa29370 | |||
| 7034e2015e | |||
| 0a890ad871 | |||
| b52bb1124e | |||
| 41f33af51b | |||
| 6b4763c7da | |||
| be07889a45 | |||
| 1b3243c09c | |||
| fee1c9eccf | |||
| 084f6c31cb | |||
| 592bf76eb0 | |||
| 6f0aee1cc5 | |||
| 3575e20137 | |||
| f69f529258 | |||
| 3e7416ca7d | |||
| cf324c5d8c | |||
| 9da883a50c | |||
| ea3e03aaba | |||
| 8d9fdfeafc | |||
| b2a8285ecb | |||
| 162e8f7e51 | |||
| 6c658813cd | |||
| 0839ea385f | |||
| 68fa235412 | |||
| 417ce4b470 | |||
| 48deaa5f57 | |||
| e9f7b8bc0c | |||
| e31861af2e | |||
| 1af482d950 | |||
| dd2436925b | |||
| b92b69564b | |||
| a4fa163333 | |||
| 635d228c86 | |||
| 75725db6fb | |||
| 5cd8475143 | |||
| 5629f37939 | |||
| 08ec04d8b6 | |||
| c0b46f364a | |||
| 303d03d43c | |||
| 8c5f74e8bb | |||
| 94832262e3 | |||
| aefbfd52e9 | |||
| f3f0689bd4 | |||
| 5198d4c5fc | |||
| 123f2d3e4e | |||
| 3c750c3c92 | |||
| 17b29cd19f | |||
| cf1077bec4 | |||
| 4e2e4e95e0 | |||
| 61d64e7ae4 | |||
| 883797c495 | |||
| 0113971877 | |||
| 664b0c06a6 | |||
| bd4c75a98e | |||
| d35840409b | |||
| abaef9ba87 | |||
| b15d8bdd2e | |||
| 718997327a | |||
| fdfefbb94d | |||
| 2b865a55ac | |||
| 8138215597 | |||
| 7cc0c7a1cc | |||
| 50f561dbd2 | |||
| 4c647aaa19 | |||
| 48b1d616c5 | |||
| 693c37d6d6 | |||
| d525c04826 | |||
| c170edbdfc | |||
| 66e40155a9 | |||
| 59ad1a9b00 | |||
| a5b536e218 | |||
| 0e6c2e790d | |||
| 5761e73061 | |||
| 34c761e9db | |||
| 87e3813636 | |||
| 361ff0315c | |||
| 2bb227d058 | |||
| 99dc69e839 | |||
| d78fde8099 | |||
| 5d0c8956d6 | |||
| c9537af062 | |||
| dfb5b3a8ce | |||
| a177e44583 | |||
| 7ae03729f3 | |||
| 898ec21a25 | |||
| 6d7d8dec02 | |||
| ea7e2ec5ec | |||
| a5b8e2aa2f | |||
| 123333d9c2 | |||
| 0c4fa1d96a | |||
| e5805e8c69 | |||
| bf2d45a012 | |||
| a7122788b1 | |||
| 237c58f2b0 | |||
| efa23e4a1d | |||
| c109cee7ef | |||
| e111d39c54 | |||
| 66306464e1 | |||
| dd34ac1722 | |||
| 34cb222b33 | |||
| a0276f7e81 | |||
| d39ef156de | |||
| f464dc7fb8 | |||
| d29b27a5df | |||
| 5346ca9046 | |||
| 6d5b552bb7 | |||
| aadc6aa504 | |||
| e8c3dfa13e | |||
| 836d62f4aa | |||
| 9eea93cc6e | |||
| 308cb55b6b | |||
| 75ada78f8f | |||
| ecd86e3a12 | |||
| c1aa5eb717 | |||
| d2fed1198b | |||
| a9f9261dbd | |||
| 161e0d6e97 | |||
| 3efe511f42 | |||
| 5d04c2e50a | |||
| 7b26b7ea4c | |||
| 9d1063c6b2 | |||
| 5ff7632d32 | |||
| e6fb41504c | |||
| a800f731dd | |||
| f1a9fbb74e | |||
| cf81a73526 | |||
| 65036fffe8 | |||
| a69934a7e3 | |||
| 9400457bf2 | |||
| 5060329721 | |||
| 07ab1d60e8 | |||
| 7377a82e19 | |||
| f82e3ac808 | |||
| 1a6cd1de04 | |||
| 90e6f685b7 | |||
| 0fc825dac1 | |||
| dbb27efe3e | |||
| 2d3d2e783e | |||
| 6ae1defa35 | |||
| d55e77fb90 | |||
| 7fb9ae71e7 | |||
| 9419555149 | |||
| ab634f8beb | |||
| 9503b80d57 | |||
| bc870226e5 | |||
| 7e106ae011 | |||
| 958e00e231 | |||
| ab187d225d | |||
| 9f5711d41d | |||
| cdb2773127 | |||
| d12532ccc1 | |||
| 53e9f05a10 | |||
| 60e7ab95bc | |||
| ae552e2b46 | |||
| 145b52f343 | |||
| 57b8fac0d5 | |||
| 16a4a5ba46 | |||
| 3d37c83532 | |||
| b02fa701b8 | |||
| 37b7c82c64 | |||
| 1deb27df06 | |||
| 84ed3d5767 | |||
| fc909a3db2 | |||
| 2f7d4cd80d | |||
| 03ccbf3613 | |||
| 1868465319 | |||
| ff473e2fcc | |||
| a3c38eec86 | |||
| 2015c847e8 | |||
| 1b583ed984 | |||
| 11191c746a | |||
| abedd3c5bf | |||
| 501ba5135b | |||
| a76c98c348 | |||
| 9dcdc1a339 | |||
| 6d1f386203 | |||
| ff9bbf0a49 | |||
| 66e24c8d40 | |||
| 34f117c631 | |||
| 21f2f16889 | |||
| f6fa7c422d | |||
| 6903b84bb6 | |||
| 0978b8fb4f | |||
| d014583e88 | |||
| a747f51b9d | |||
| 8300885ab6 | |||
| b489eed4ef | |||
| 0b57771d76 | |||
| 8a32a8271c | |||
| c3e716dafd | |||
| 119a11eb8d | |||
| e464d14842 | |||
| 905f46359a | |||
| 8e7bf1f908 | |||
| 3a1524ae6d | |||
| 5c04befea3 | |||
| ae3584cdff | |||
| a60578c82c | |||
| 74558a500c | |||
| d963d8c8c1 | |||
| 853892c24f | |||
| 641f939e3d | |||
| af77504eaf | |||
| 62649d6468 | |||
| bb914e605e | |||
| 62ee88bbfa | |||
| 99c964bb4a | |||
| 09ceaef3e9 | |||
| a82900af55 | |||
| 5ef589f31a | |||
| cd719f134d | |||
| f69eb219b5 | |||
| 0ffe17ee3d | |||
| 4ac647a215 | |||
| 872536c035 | |||
| c7a6a6fff0 | |||
| 2534655bc8 | |||
| 0cb82d70fd | |||
| acac5a2ad6 | |||
| 9ec15ad2ca | |||
| a9b7d56d0b | |||
| e9ca1eb538 | |||
| 0532800895 | |||
| ad50ca6e60 | |||
| c1ad999c25 | |||
| 4accd1264d | |||
| e1f3da3aa8 | |||
| 4bf9a7950b | |||
| 8285c31bf1 | |||
| 230be66fa9 | |||
| 428d7ec94a | |||
| 2c53f934c9 | |||
| 08785cb272 | |||
| bd0207c938 | |||
| 6fad737617 | |||
| af4148d985 | |||
| 922eaf4d42 | |||
| 4b5153950f | |||
| 78010d2bd7 | |||
| 6cc0017826 | |||
| 8a9131c3dc | |||
| 85c2ed1bf2 | |||
| aca1df634d | |||
| 053a3c1a53 | |||
| 429aa90e0d | |||
| 4f792b347d | |||
| 468c315087 | |||
| 6d8ced21b9 | |||
| b3d5fc149e | |||
| 277b7a4536 | |||
| 43886511b9 | |||
| 8b3eb5b02d | |||
| 054ef87886 | |||
| 39c65d9e9a | |||
| b97bbbfa3d | |||
| ace6ba8096 | |||
| a2b87d84e9 | |||
| b90d61b27c | |||
| 85606e3e7e | |||
| 1fc85d49bd | |||
| a5cfb4e638 | |||
| 38754bf062 | |||
| f1818ed2ff | |||
| 352ad17715 | |||
| e50b8d9632 | |||
| 2107061a46 | |||
| 61f57b4895 | |||
| d34273abff | |||
| 0aff0f0362 | |||
| 68949b69bc | |||
| c56c77d3a1 | |||
| dc82ce395a | |||
| fd63a2209b | |||
| 2a29483456 | |||
| 4f10562980 | |||
| a26ec37f59 | |||
| 779ad93bcb | |||
| 1ec0219473 | |||
| 6863928b06 | |||
| aa4dca11f0 | |||
| dc6ab820ce | |||
| be0fa4d60b | |||
| a86d2272af | |||
| 61a67892ac | |||
| 388d5954cb | |||
| 08550d413e | |||
| b89294561b | |||
| 20977558cc | |||
| 630d8fdb43 | |||
| c4c7e6caf4 | |||
| 8a8fea1257 | |||
| 0e0f297a3f | |||
| fd2c0f2b24 | |||
| ecc6e3888d | |||
| 47c073aaf3 | |||
| 07476a4349 | |||
| 817148f3a1 | |||
| bd4271cd8c | |||
| b1804fc346 | |||
| a3886c2179 | |||
| f258b5bf1c | |||
| a05361011f | |||
| 6b34a77251 | |||
| afb1adee3d | |||
| 22fa7a37f3 | |||
| 6a58bfc574 | |||
| 64124c60fc | |||
| 9a0066de62 | |||
| 22c7c7403b | |||
| 83db8e4b15 | |||
| 25f2e121e7 | |||
| 1325a145d8 | |||
| 9bc49c0b29 | |||
| 8e84e5b0f3 | |||
| a42e6b0c45 | |||
| 51bb7a9854 | |||
| 62580b5719 | |||
| 15cfd5ce5c | |||
| 11c89c4090 | |||
| 4a12cb9f27 | |||
| 32f575eddd | |||
| fbb4cb3b1c | |||
| c9d2d5e8ab | |||
| 93763192f2 | |||
| 80e0eae6b0 | |||
| 4e3d735b90 | |||
| 60e5a7da28 | |||
| 997b5ba889 | |||
| b3e7ca1963 | |||
| 5a82d695c1 | |||
| 64a0427150 | |||
| f6aafc1d6b | |||
| bca5532df8 | |||
| 72eeadd9aa | |||
| 0af55794f6 | |||
| 25a6c53533 | |||
| 9f9172c775 | |||
| 320e0db417 | |||
| cb8362d447 | |||
| 45a83fc53c | |||
| 3411bd1c1d | |||
| 6ab0a77364 | |||
| 281bae4116 | |||
| 218c692fe0 | |||
| fa69b581e1 | |||
| bd0baceeca | |||
| e71c837472 | |||
| 782aaabd07 | |||
| 9014325a7c | |||
| 8ae9276732 | |||
| 79a3aa5916 | |||
| 733c5db228 | |||
| 6171c621a7 | |||
| fc11856a28 | |||
| 802568856c | |||
| 127fb67185 | |||
| 5db039bbce | |||
| b0726b9733 | |||
| 8a3365d18e | |||
| 2ae5b1a4f8 | |||
| f9515d7126 | |||
| b56679a97c | |||
| d1b123964a | |||
| 991f7c4958 | |||
| 770619c39e | |||
| 4ad5450b80 | |||
| 49ce7fe885 | |||
| e66f63262b | |||
| 94bd5da68a | |||
| 3eee95caf2 | |||
| 5c638c630a | |||
| a6ec9d7a1c | |||
| 374c70c0e3 | |||
| 40771066d4 | |||
| 22a7ef43ce | |||
| 05f22d1cee | |||
| ebf56a86ab | |||
| 2ba59e8943 | |||
| 4e4ea25e7f | |||
| 83be1de04c | |||
| c8251ed82f | |||
| 2335ea0c4d | |||
| 5d874e9063 | |||
| f2c080d25f | |||
| 975da97b4a | |||
| 37617589a6 | |||
| 5c9f0db903 | |||
| 28abf0c175 | |||
| 13749feab4 | |||
| c1e77b7e09 | |||
| 962a5e93f7 | |||
| c3b9b8d5ae | |||
| 1ad076c522 | |||
| b01777fcd1 | |||
| 55a5532c2e | |||
| adb928941a | |||
| f92c1fc527 | |||
| 3ae7279ebc | |||
| 66287c2d0e | |||
| 5d37626981 | |||
| d0ed3b979d | |||
| fa256aec9f | |||
| 86834c5a15 | |||
| c2046157d6 | |||
| cdb2cc89c0 | |||
| 4964c09a77 | |||
| ef34b2c9ce | |||
| 9afe242293 | |||
| 136d93d373 | |||
| 3102cec5b8 | |||
| e28eb9da04 | |||
| 754ed86dfb | |||
| e352b07055 | |||
| fdea242b50 | |||
| 7058e4f2c4 | |||
| 704a5dbd73 | |||
| fbd4ce8c2e | |||
| cb3ce71cdc | |||
| 7f44f2f5e4 | |||
| 66efbe63f0 | |||
| 49a1308875 | |||
| 4332580c01 | |||
| 72ecf2d2af | |||
| 0f854e46d8 | |||
| 4564f38e1a | |||
| 7e06bf6705 | |||
| 3dd8b6ad33 | |||
| 3e0a975a88 | |||
| 6aa1c5b1eb | |||
| d780cf64c2 | |||
| 1fb5a8cd6f | |||
| 8925460718 | |||
| 9797701881 | |||
| 8a50b180c0 | |||
| 159190d187 | |||
| 989d543a1f | |||
| fcc3a1b2f6 | |||
| cfdeb87093 | |||
| 74eef34ec2 | |||
| 2e87d5322f | |||
| e89a49f39a | |||
| 5d3fd91f0b | |||
| f455d22893 | |||
| c00f528098 | |||
| 6f02ad60eb | |||
| ca6c0791ae | |||
| ee485dbfd8 | |||
| 2ecaa12647 | |||
| 580e099cb7 | |||
| 83e50f0d38 | |||
| 48c770b475 | |||
| ba67101942 | |||
| 72efde09b3 | |||
| 76c49170bd | |||
| 150aa7e2c2 | |||
| 0762fec696 | |||
| 1447496efa | |||
| 6fb9eafef0 | |||
| 16bde5e9fc | |||
| 7b85c44444 | |||
| 87d553fca2 | |||
| ba050d4c86 | |||
| 90cd7f49fd | |||
| 29b42290c7 | |||
| 6c6c64bb3b | |||
| ae7db2cf9f | |||
| 1afab62dec | |||
| 4171ca992e | |||
| e1166a8a80 | |||
| 1dc6c799e1 | |||
| ae1e075696 | |||
| 74a7f71894 | |||
| f2e149d3b3 | |||
| 92c0bf9cdc | |||
| 020b050fb1 | |||
| 08d71cede3 | |||
| be1f6cfbae | |||
| 9aa5e139cf | |||
| 1d5c3d62dd | |||
| 0e611ae94b | |||
| 104613b056 | |||
| 99577ad874 | |||
| 908a46d27d | |||
| 85677b952f | |||
| f4773ef1e4 | |||
| 5eaa6183b5 | |||
| 4036d40c58 | |||
| 0b80cbb0dc | |||
| 79cb386d82 | |||
| 09be68831b | |||
| 0ac13c2b81 | |||
| 94ef38e3cc | |||
| 76882ac01c | |||
| 0d315218dd | |||
| 59945fbe91 | |||
| c4962ec017 | |||
| 58d60bc899 | |||
| 5dd0a78423 | |||
| 141ea7cc2d | |||
| a488d1dbf7 | |||
| ec130d0763 | |||
| 30729e3f93 | |||
| 241d7402cc | |||
| 3b14aba1a2 | |||
| b02205f7cd | |||
| c27bc0023f | |||
| 9698a7c5be | |||
| 071e2f8bb4 | |||
| 726d3f7024 | |||
| 3503aa43b4 | |||
| e865b46304 | |||
| 494f96495e | |||
| 7ed2081513 | |||
| 5110313657 | |||
| 24990e26c8 | |||
| 3ca086bcec | |||
| 7d103c4ee8 | |||
| 5fed6f5681 | |||
| 616539ecb0 | |||
| 9e99e88d27 | |||
| 0e39400dd0 | |||
| 2ba796de01 | |||
| efe2535977 | |||
| c17352b8af | |||
| b1fc3ff17a | |||
| 485dafb616 | |||
| bf25a3a601 | |||
| 14fcd0b2f9 | |||
| cb24714faa | |||
| 36199334f0 | |||
| 72c7e65dfa | |||
| a4ad301b44 | |||
| 72569321fa | |||
| 1600a80124 | |||
| 80c1a02377 | |||
| 0c41909454 | |||
| 2b5d889bb9 | |||
| 2c2a71d429 | |||
| f900414e38 | |||
| 1c72766c34 | |||
| 302f3c1467 | |||
| 9415419324 | |||
| 602592a354 | |||
| 1a4cba5fa5 | |||
| 018853e976 | |||
| 651bd33b73 | |||
| f4644ce685 | |||
| 0a422e9a89 | |||
| 432c16c89f | |||
| 241706cbbf | |||
| 33dd0f9922 | |||
| ed8bb354e5 | |||
| e373392f64 | |||
| 292fd2f39e | |||
| 1c9cb8286f | |||
| 8296061b64 | |||
| bb5d84c29c | |||
| eae857bcf7 | |||
| d604d198ab | |||
| 40b5162fdf | |||
| 7934ad6904 | |||
| 858b010caa | |||
| 36791d2f48 | |||
| 08f9cffed9 | |||
| 783c0ba846 | |||
| 37cd2351e2 | |||
| be1e250a6b | |||
| f86896e5af | |||
| 7ad4f61564 | |||
| adf06a2b0d | |||
| d6aa2b2512 | |||
| a95b1f0dae | |||
| 0a8af94610 | |||
| f1c7b95b33 | |||
| 2c27c0f58a | |||
| e4a7e23c46 | |||
| 6f15adf57f | |||
| 1966b40d01 | |||
| 24ce4d098e | |||
| 98619f9bc9 | |||
| 1efeb2515d | |||
| ccf837b2bf | |||
| e558863743 | |||
| 43f21dfe92 | |||
| 4172eae87e | |||
| 26f2c61068 | |||
| f97bed2607 | |||
| 8ef7155c70 | |||
| f5b2556b70 | |||
| 2c6e8f88fb | |||
| 25068b1e83 | |||
| 1f36eb3a9a | |||
| a9ed577d05 | |||
| 782d614082 | |||
| 0629c00b07 | |||
| b90d5bb205 | |||
| cbc824c80a | |||
| 0c9be40b86 | |||
| c96abd706d | |||
| 0ae5872783 | |||
| 2cff10e0d2 | |||
| cab78f557d | |||
| 04353aa1a5 | |||
| 35121a66e9 | |||
| e726ed2c19 | |||
| 503446afc7 | |||
| 2063f662d3 | |||
| d7381399aa | |||
| d05b497cdb | |||
| ef919be587 | |||
| fff31e0f4f | |||
| cdd6fc7c1e | |||
| 74bc36a2dc | |||
| 48328ae52c | |||
| a86f4f8e23 | |||
| 0a1e048268 | |||
| 6fc5efd6ba | |||
| 2d795b593d | |||
| 20628ec75c | |||
| 10d1ccb009 | |||
| fcc37c9581 | |||
| 43cd391543 | |||
| 18d2df33f7 | |||
| a85daa5617 | |||
| 48dc4ce3e2 | |||
| d07bac89a0 | |||
| 5d32ad6bc4 | |||
| 397b0a3e7e | |||
| 259961632d | |||
| cb1d6382ec | |||
| 8714a69a13 | |||
| 3ae0ea2de7 | |||
| 1879a9f4c7 | |||
| 3938717b04 | |||
| 1208b688f1 | |||
| 0ad7ee5a32 | |||
| 7a4e68e6b9 | |||
| 71222b247f | |||
| 95db811943 | |||
| 2dbc817132 | |||
| 7a8bd96edc | |||
| c5e9686a95 | |||
| c914edf616 | |||
| 656bfcb6bd | |||
| 7434dfe6fa | |||
| e67aa63a50 | |||
| 06fc786416 | |||
| d5e46f2b42 | |||
| c003a92408 | |||
| 09e6f10b60 | |||
| c961c22cd7 | |||
| 105a821069 | |||
| 670993f769 | |||
| 60a571f291 | |||
| 20a0cb2cd9 | |||
| 51e70be04d | |||
| ac65b808c6 | |||
| eb9ddf3c47 | |||
| 80993e9f77 | |||
| b7a6d257d5 | |||
| 7022486e93 | |||
| 83f5a9d34e | |||
| 431e1051b8 | |||
| f8ab5c3842 | |||
| 101d095f45 | |||
| 8481de2b47 | |||
| c973f133de | |||
| d23cdcbe57 | |||
| 9a52175bd6 | |||
| 4275218841 | |||
| 663a2c2a16 | |||
| da58a60ad5 | |||
| 2c26063f4b | |||
| b19e47783b | |||
| aee266eea0 | |||
| 8304769953 | |||
| 914a74bca9 | |||
| b965dbff70 | |||
| 9f9bcd2467 | |||
| b3353afe3c | |||
| 4e3081afee | |||
| 578a6a2df3 | |||
| aa42ddd3f1 | |||
| 69738c337f | |||
| 12f099fd54 | |||
| 38932f306d | |||
| 5e7e1077a1 | |||
| 8f85311332 | |||
| 6eb2887a5a | |||
| 54f4fd3101 | |||
| 64a22acf84 | |||
| 4e5877923d | |||
| ceaa1a4dd1 | |||
| 9e1ad46c90 | |||
| d5a3fefd8b | |||
| d85332aca1 | |||
| 10c3f6d85a | |||
| ea4764f1f9 | |||
| fe753b0bc8 | |||
| 04608269fe | |||
| 6addd64cf0 |
46
.example/container/garray/basic_array.go
Normal file
46
.example/container/garray/basic_array.go
Normal 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())
|
||||
}
|
||||
22
.example/container/garray/json_marshal.go
Normal file
22
.example/container/garray/json_marshal.go
Normal 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))
|
||||
}
|
||||
19
.example/container/garray/json_unmarshal.go
Normal file
19
.example/container/garray/json_unmarshal.go
Normal 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)
|
||||
}
|
||||
40
.example/container/garray/sorted_array_basic.go
Normal file
40
.example/container/garray/sorted_array_basic.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 自定义排序数组,降序排序(SortedIntArray管理的数据是升序)
|
||||
a := garray.NewSortedArray(func(v1, v2 interface{}) int {
|
||||
if v1.(int) < v2.(int) {
|
||||
return 1
|
||||
}
|
||||
if v1.(int) > v2.(int) {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
// 添加数据
|
||||
a.Add(2)
|
||||
a.Add(3)
|
||||
a.Add(1)
|
||||
fmt.Println(a.Slice())
|
||||
|
||||
// 添加重复数据
|
||||
a.Add(3)
|
||||
fmt.Println(a.Slice())
|
||||
|
||||
// 检索数据,返回最后对比的索引位置,检索结果
|
||||
// 检索结果:0: 匹配; <0:参数小于对比值; >0:参数大于对比值
|
||||
fmt.Println(a.Search(1))
|
||||
|
||||
// 设置不可重复
|
||||
a.SetUnique(true)
|
||||
fmt.Println(a.Slice())
|
||||
a.Add(1)
|
||||
fmt.Println(a.Slice())
|
||||
}
|
||||
23
.example/container/garray/sorted_string_array.go
Normal file
23
.example/container/garray/sorted_string_array.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/garray"
|
||||
)
|
||||
|
||||
func main() {
|
||||
array := garray.NewSortedStrArray()
|
||||
array.Add("9")
|
||||
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]
|
||||
}
|
||||
22
.example/container/glist/basic.go
Normal file
22
.example/container/glist/basic.go
Normal 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)
|
||||
e := l.PushFront(0)
|
||||
// Insert
|
||||
l.InsertBefore(e, -1)
|
||||
l.InsertAfter(e, "a")
|
||||
fmt.Println(l)
|
||||
// Pop
|
||||
fmt.Println(l.PopFront())
|
||||
fmt.Println(l.PopBack())
|
||||
fmt.Println(l)
|
||||
}
|
||||
23
.example/container/glist/json_marshal.go
Normal file
23
.example/container/glist/json_marshal.go
Normal 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))
|
||||
}
|
||||
19
.example/container/glist/json_unmarshal.go
Normal file
19
.example/container/glist/json_unmarshal.go
Normal 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)
|
||||
}
|
||||
74
.example/container/gmap/basic.go
Normal file
74
.example/container/gmap/basic.go
Normal file
@ -0,0 +1,74 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建一个默认的gmap对象,
|
||||
// 默认情况下该gmap对象不支持并发安全特性,
|
||||
// 初始化时可以给定true参数开启并发安全特性,用以并发安全场景。
|
||||
m := gmap.New()
|
||||
|
||||
// 设置键值对
|
||||
for i := 0; i < 10; i++ {
|
||||
m.Set(i, i)
|
||||
}
|
||||
// 查询大小
|
||||
fmt.Println(m.Size())
|
||||
// 批量设置键值对(不同的数据类型对象参数不同)
|
||||
m.Sets(map[interface{}]interface{}{
|
||||
10: 10,
|
||||
11: 11,
|
||||
})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 查询是否存在
|
||||
fmt.Println(m.Contains(1))
|
||||
|
||||
// 查询键值
|
||||
fmt.Println(m.Get(1))
|
||||
|
||||
// 删除数据项
|
||||
m.Remove(9)
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 批量删除
|
||||
m.Removes([]interface{}{10, 11})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 当前键名列表(随机排序)
|
||||
fmt.Println(m.Keys())
|
||||
// 当前键值列表(随机排序)
|
||||
fmt.Println(m.Values())
|
||||
|
||||
// 查询键名,当键值不存在时,写入给定的默认值
|
||||
fmt.Println(m.GetOrSet(100, 100))
|
||||
|
||||
// 删除键值对,并返回对应的键值
|
||||
fmt.Println(m.Remove(100))
|
||||
|
||||
// 遍历map
|
||||
m.Iterator(func(k interface{}, v interface{}) bool {
|
||||
fmt.Printf("%v:%v ", k, v)
|
||||
return true
|
||||
})
|
||||
|
||||
// 自定义写锁操作
|
||||
m.LockFunc(func(m map[interface{}]interface{}) {
|
||||
m[99] = 99
|
||||
})
|
||||
|
||||
// 自定义读锁操作
|
||||
m.RLockFunc(func(m map[interface{}]interface{}) {
|
||||
fmt.Println(m[99])
|
||||
})
|
||||
|
||||
// 清空map
|
||||
m.Clear()
|
||||
|
||||
// 判断map是否为空
|
||||
fmt.Println(m.IsEmpty())
|
||||
}
|
||||
19
.example/container/gmap/gmap_json_marshal.go
Normal file
19
.example/container/gmap/gmap_json_marshal.go
Normal 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))
|
||||
}
|
||||
14
.example/container/gmap/gmap_json_unmarshal.go
Normal file
14
.example/container/gmap/gmap_json_unmarshal.go
Normal 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())
|
||||
}
|
||||
26
.example/container/gmap/gmap_map_clone_safe.go
Normal file
26
.example/container/gmap/gmap_map_clone_safe.go
Normal 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(true)
|
||||
m1.Set("1", "1")
|
||||
|
||||
m2 := m1.Map()
|
||||
m2["2"] = "2"
|
||||
|
||||
g.Dump(m1.Clone())
|
||||
g.Dump(m2)
|
||||
//output:
|
||||
//{
|
||||
// "1": "1"
|
||||
//}
|
||||
//
|
||||
//{
|
||||
// "1": "1",
|
||||
// "2": "2"
|
||||
//}
|
||||
}
|
||||
31
.example/container/gmap/gmap_maps.go
Normal file
31
.example/container/gmap/gmap_maps.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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()
|
||||
linkMap := gmap.NewListMap()
|
||||
treeMap := gmap.NewTreeMap(gutil.ComparatorInt)
|
||||
for _, v := range array {
|
||||
hashMap.Set(v, v)
|
||||
}
|
||||
for _, v := range array {
|
||||
linkMap.Set(v, v)
|
||||
}
|
||||
for _, v := range array {
|
||||
treeMap.Set(v, v)
|
||||
}
|
||||
fmt.Println("HashMap Keys:", hashMap.Keys())
|
||||
fmt.Println("HashMap Values:", hashMap.Values())
|
||||
fmt.Println("LinkMap Keys:", linkMap.Keys())
|
||||
fmt.Println("LinkMap Values:", linkMap.Values())
|
||||
fmt.Println("TreeMap Keys:", treeMap.Keys())
|
||||
fmt.Println("TreeMap Values:", treeMap.Values())
|
||||
}
|
||||
63
.example/container/gmap/gmap_treemap.go
Normal file
63
.example/container/gmap/gmap_treemap.go
Normal file
@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
m := gmap.NewTreeMap(gutil.ComparatorInt)
|
||||
|
||||
// 设置键值对
|
||||
for i := 0; i < 10; i++ {
|
||||
m.Set(i, i)
|
||||
}
|
||||
// 查询大小
|
||||
fmt.Println(m.Size())
|
||||
// 批量设置键值对(不同的数据类型对象参数不同)
|
||||
m.Sets(map[interface{}]interface{}{
|
||||
10: 10,
|
||||
11: 11,
|
||||
})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 查询是否存在
|
||||
fmt.Println(m.Contains(1))
|
||||
|
||||
// 查询键值
|
||||
fmt.Println(m.Get(1))
|
||||
|
||||
// 删除数据项
|
||||
m.Remove(9)
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 批量删除
|
||||
m.Removes([]interface{}{10, 11})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 当前键名列表(随机排序)
|
||||
fmt.Println(m.Keys())
|
||||
// 当前键值列表(随机排序)
|
||||
fmt.Println(m.Values())
|
||||
|
||||
// 查询键名,当键值不存在时,写入给定的默认值
|
||||
fmt.Println(m.GetOrSet(100, 100))
|
||||
|
||||
// 删除键值对,并返回对应的键值
|
||||
fmt.Println(m.Remove(100))
|
||||
|
||||
// 遍历map
|
||||
m.IteratorAsc(func(k interface{}, v interface{}) bool {
|
||||
fmt.Printf("%v:%v ", k, v)
|
||||
return true
|
||||
})
|
||||
fmt.Println()
|
||||
|
||||
// 清空map
|
||||
m.Clear()
|
||||
|
||||
// 判断map是否为空
|
||||
fmt.Println(m.IsEmpty())
|
||||
}
|
||||
26
.example/container/gpool/gpool.go
Normal file
26
.example/container/gpool/gpool.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gpool"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建一个对象池,过期时间为1000毫秒
|
||||
p := gpool.New(1000*time.Millisecond, nil)
|
||||
|
||||
// 从池中取一个对象,返回nil及错误信息
|
||||
fmt.Println(p.Get())
|
||||
|
||||
// 丢一个对象到池中
|
||||
p.Put(1)
|
||||
|
||||
// 重新从池中取一个对象,返回1
|
||||
fmt.Println(p.Get())
|
||||
|
||||
// 等待1秒后重试,发现对象已过期,返回nil及错误信息
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println(p.Get())
|
||||
}
|
||||
33
.example/container/gpool/gpool_expirefunc.go
Normal file
33
.example/container/gpool/gpool_expirefunc.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gpool"
|
||||
"github.com/gogf/gf/net/gtcp"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建对象复用池,对象过期时间为3000毫秒,并给定创建及销毁方法
|
||||
p := gpool.New(3000*time.Millisecond, func() (interface{}, error) {
|
||||
return gtcp.NewConn("www.baidu.com:80")
|
||||
}, func(i interface{}) {
|
||||
glog.Println("expired")
|
||||
i.(*gtcp.Conn).Close()
|
||||
})
|
||||
conn, err := p.Get()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
result, err := conn.(*gtcp.Conn).SendRecv([]byte("HEAD / HTTP/1.1\n\n"), -1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(string(result))
|
||||
// 丢回池中以便重复使用
|
||||
p.Put(conn)
|
||||
// 等待一定时间观察过期方法调用
|
||||
time.Sleep(4 * time.Second)
|
||||
}
|
||||
34
.example/container/gqueue/gqueue.go
Normal file
34
.example/container/gqueue/gqueue.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
q := gqueue.New()
|
||||
// 数据生产者,每隔1秒往队列写数据
|
||||
gtimer.SetInterval(time.Second, func() {
|
||||
v := gtime.Now().String()
|
||||
q.Push(v)
|
||||
fmt.Println("Push:", v)
|
||||
})
|
||||
|
||||
// 3秒后关闭队列
|
||||
gtimer.SetTimeout(3*time.Second, func() {
|
||||
q.Close()
|
||||
})
|
||||
|
||||
// 消费者,不停读取队列数据并输出到终端
|
||||
for {
|
||||
if v := q.Pop(); v != nil {
|
||||
fmt.Println(" Pop:", v)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
28
.example/container/gqueue/gqueue2.go
Normal file
28
.example/container/gqueue/gqueue2.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
q := gqueue.New()
|
||||
// 数据生产者,每隔1秒往队列写数据
|
||||
gtimer.SetInterval(time.Second, func() {
|
||||
for i := 0; i < 10; i++ {
|
||||
q.Push(i)
|
||||
}
|
||||
})
|
||||
|
||||
// 消费者,不停读取队列数据并输出到终端
|
||||
for {
|
||||
if v := q.Pop(); v != nil {
|
||||
fmt.Println(" Pop:", v)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
30
.example/container/gqueue/gqueue3.go
Normal file
30
.example/container/gqueue/gqueue3.go
Normal file
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/container/gqueue"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/os/gtimer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
queue := gqueue.New()
|
||||
// 数据生产者,每隔1秒往队列写数据
|
||||
gtimer.SetInterval(time.Second, func() {
|
||||
queue.Push(gtime.Now().String())
|
||||
})
|
||||
|
||||
// 消费者,不停读取队列数据并输出到终端
|
||||
for {
|
||||
select {
|
||||
case v := <-queue.C:
|
||||
if v != nil {
|
||||
fmt.Println(v)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
.example/container/gring/gring.go
Normal file
28
.example/container/gring/gring.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gring"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r1 := gring.New(10)
|
||||
for i := 0; i < 5; i++ {
|
||||
r1.Set(i).Next()
|
||||
}
|
||||
fmt.Println("Len:", r1.Len())
|
||||
fmt.Println("Cap:", r1.Cap())
|
||||
fmt.Println(r1.SlicePrev())
|
||||
fmt.Println(r1.SliceNext())
|
||||
|
||||
r2 := gring.New(10)
|
||||
for i := 0; i < 10; i++ {
|
||||
r2.Set(i).Next()
|
||||
}
|
||||
fmt.Println("Len:", r2.Len())
|
||||
fmt.Println("Cap:", r2.Cap())
|
||||
fmt.Println(r2.SlicePrev())
|
||||
fmt.Println(r2.SliceNext())
|
||||
|
||||
}
|
||||
58
.example/container/gring/gring_josephus.go
Normal file
58
.example/container/gring/gring_josephus.go
Normal file
@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gring"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
position int // 位置
|
||||
alive bool // 是否存活
|
||||
}
|
||||
|
||||
const (
|
||||
playerCount = 41 // 玩家人数
|
||||
startPos = 1 // 开始报数位置
|
||||
)
|
||||
|
||||
var (
|
||||
deadline = 3
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 关闭并发安全,当前场景没有必要
|
||||
r := gring.New(playerCount, false)
|
||||
|
||||
// 设置所有玩家初始值
|
||||
for i := 1; i <= playerCount; i++ {
|
||||
r.Put(&Player{i, true})
|
||||
}
|
||||
|
||||
// 如果开始报数的位置不为1,则设置开始位置
|
||||
if startPos > 1 {
|
||||
r.Move(startPos - 1)
|
||||
}
|
||||
|
||||
counter := 1 // 报数从1开始,因为下面的循环从第二个开始计算
|
||||
deadCount := 0 // 死亡人数,初始值为0
|
||||
|
||||
// 直到所有人都死亡,否则循环一直执行
|
||||
for deadCount < playerCount {
|
||||
// 跳到下一个人
|
||||
r.Next()
|
||||
|
||||
// 如果是活着的人,则报数
|
||||
if r.Val().(*Player).alive {
|
||||
counter++
|
||||
}
|
||||
|
||||
// 如果报数为deadline,则此人淘汰出局
|
||||
if counter == deadline {
|
||||
r.Val().(*Player).alive = false
|
||||
fmt.Printf("Player %d died!\n", r.Val().(*Player).position)
|
||||
deadCount++
|
||||
counter = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
53
.example/container/gset/gset1.go
Normal file
53
.example/container/gset/gset1.go
Normal file
@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gset"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建一个非并发安全的集合对象
|
||||
s := gset.New(true)
|
||||
|
||||
// 添加数据项
|
||||
s.Add(1)
|
||||
|
||||
// 批量添加数据项
|
||||
s.Add([]interface{}{1, 2, 3}...)
|
||||
|
||||
// 集合数据项大小
|
||||
fmt.Println(s.Size())
|
||||
|
||||
// 集合中是否存在指定数据项
|
||||
fmt.Println(s.Contains(2))
|
||||
|
||||
// 返回数据项slice
|
||||
fmt.Println(s.Slice())
|
||||
|
||||
// 删除数据项
|
||||
s.Remove(3)
|
||||
|
||||
// 遍历数据项
|
||||
s.Iterator(func(v interface{}) bool {
|
||||
fmt.Println("Iterator:", v)
|
||||
return true
|
||||
})
|
||||
|
||||
// 将集合转换为字符串
|
||||
fmt.Println(s.String())
|
||||
|
||||
// 并发安全写锁操作
|
||||
s.LockFunc(func(m map[interface{}]struct{}) {
|
||||
m[4] = struct{}{}
|
||||
})
|
||||
|
||||
// 并发安全读锁操作
|
||||
s.RLockFunc(func(m map[interface{}]struct{}) {
|
||||
fmt.Println(m)
|
||||
})
|
||||
|
||||
// 清空集合
|
||||
s.Clear()
|
||||
fmt.Println(s.Size())
|
||||
}
|
||||
23
.example/container/gset/gset2.go
Normal file
23
.example/container/gset/gset2.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gset"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s1 := gset.NewFrom(g.Slice{1, 2, 3})
|
||||
s2 := gset.NewFrom(g.Slice{4, 5, 6})
|
||||
s3 := gset.NewFrom(g.Slice{1, 2, 3, 4, 5, 6, 7})
|
||||
|
||||
// 交集
|
||||
fmt.Println(s3.Intersect(s1).Slice())
|
||||
// 差集
|
||||
fmt.Println(s3.Diff(s1).Slice())
|
||||
// 并集
|
||||
fmt.Println(s1.Union(s2).Slice())
|
||||
// 补集
|
||||
fmt.Println(s1.Complement(s3).Slice())
|
||||
}
|
||||
22
.example/container/gset/json_marshal.go
Normal file
22
.example/container/gset/json_marshal.go
Normal 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))
|
||||
}
|
||||
19
.example/container/gset/json_unmarshal.go
Normal file
19
.example/container/gset/json_unmarshal.go
Normal 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)
|
||||
}
|
||||
29
.example/container/gtree/gtree_avltree.go
Normal file
29
.example/container/gtree/gtree_avltree.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tree := gtree.NewAVLTree(gutil.ComparatorInt)
|
||||
for i := 0; i < 10; i++ {
|
||||
tree.Set(i, i*10)
|
||||
}
|
||||
// 打印树形
|
||||
tree.Print()
|
||||
// 前序遍历
|
||||
fmt.Println("ASC:")
|
||||
tree.IteratorAsc(func(key, value interface{}) bool {
|
||||
fmt.Println(key, value)
|
||||
return true
|
||||
})
|
||||
// 后续遍历
|
||||
fmt.Println("DESC:")
|
||||
tree.IteratorDesc(func(key, value interface{}) bool {
|
||||
fmt.Println(key, value)
|
||||
return true
|
||||
})
|
||||
}
|
||||
22
.example/container/gtree/gtree_btree.go
Normal file
22
.example/container/gtree/gtree_btree.go
Normal file
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tree := gtree.NewBTree(10, func(v1, v2 interface{}) int {
|
||||
return v1.(int) - v2.(int)
|
||||
})
|
||||
for i := 0; i < 20; i++ {
|
||||
tree.Set(i, i*10)
|
||||
}
|
||||
fmt.Println(tree.String())
|
||||
|
||||
tree.IteratorDesc(func(key, value interface{}) bool {
|
||||
fmt.Println(key, value)
|
||||
return true
|
||||
})
|
||||
}
|
||||
63
.example/container/gtree/gtree_redblackmap.go
Normal file
63
.example/container/gtree/gtree_redblackmap.go
Normal file
@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
m := gtree.NewRedBlackTree(gutil.ComparatorInt)
|
||||
|
||||
// 设置键值对
|
||||
for i := 0; i < 10; i++ {
|
||||
m.Set(i, i*10)
|
||||
}
|
||||
// 查询大小
|
||||
fmt.Println(m.Size())
|
||||
// 批量设置键值对(不同的数据类型对象参数不同)
|
||||
m.Sets(map[interface{}]interface{}{
|
||||
10: 10,
|
||||
11: 11,
|
||||
})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 查询是否存在
|
||||
fmt.Println(m.Contains(1))
|
||||
|
||||
// 查询键值
|
||||
fmt.Println(m.Get(1))
|
||||
|
||||
// 删除数据项
|
||||
m.Remove(9)
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 批量删除
|
||||
m.Removes([]interface{}{10, 11})
|
||||
fmt.Println(m.Size())
|
||||
|
||||
// 当前键名列表(随机排序)
|
||||
fmt.Println(m.Keys())
|
||||
// 当前键值列表(随机排序)
|
||||
fmt.Println(m.Values())
|
||||
|
||||
// 查询键名,当键值不存在时,写入给定的默认值
|
||||
fmt.Println(m.GetOrSet(100, 100))
|
||||
|
||||
// 删除键值对,并返回对应的键值
|
||||
fmt.Println(m.Remove(100))
|
||||
|
||||
// 遍历map
|
||||
m.IteratorAsc(func(k interface{}, v interface{}) bool {
|
||||
fmt.Printf("%v:%v ", k, v)
|
||||
return true
|
||||
})
|
||||
fmt.Println()
|
||||
|
||||
// 清空map
|
||||
m.Clear()
|
||||
|
||||
// 判断map是否为空
|
||||
fmt.Println(m.IsEmpty())
|
||||
}
|
||||
17
.example/container/gtree/gtree_redblacktree.go
Normal file
17
.example/container/gtree/gtree_redblacktree.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/container/gtree"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tree := gtree.NewRedBlackTree(func(v1, v2 interface{}) int {
|
||||
return v1.(int) - v2.(int)
|
||||
})
|
||||
for i := 0; i < 10; i++ {
|
||||
tree.Set(i, i)
|
||||
}
|
||||
tree.Print()
|
||||
tree.Flip()
|
||||
tree.Print()
|
||||
}
|
||||
21
.example/container/gtype/gtype_int.go
Normal file
21
.example/container/gtype/gtype_int.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/container/gtype"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建一个Int型的并发安全基本类型对象
|
||||
i := gtype.NewInt()
|
||||
|
||||
// 设置值
|
||||
i.Set(10)
|
||||
|
||||
// 获取值
|
||||
fmt.Println(i.Val())
|
||||
|
||||
// (整型/浮点型有效)数值 增加/删除 delta
|
||||
fmt.Println(i.Add(-1))
|
||||
}
|
||||
22
.example/container/gtype/json_marshal.go
Normal file
22
.example/container/gtype/json_marshal.go
Normal 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))
|
||||
}
|
||||
19
.example/container/gtype/json_unmarshal.go
Normal file
19
.example/container/gtype/json_unmarshal.go
Normal 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)
|
||||
}
|
||||
22
.example/container/gvar/json_marshal.go
Normal file
22
.example/container/gvar/json_marshal.go
Normal 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))
|
||||
}
|
||||
19
.example/container/gvar/json_unmarshal.go
Normal file
19
.example/container/gvar/json_unmarshal.go
Normal 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)
|
||||
}
|
||||
33
.example/container/gvar/var.go
Normal file
33
.example/container/gvar/var.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var v g.Var
|
||||
|
||||
v.Set("123")
|
||||
|
||||
fmt.Println(v.Val())
|
||||
|
||||
// 基本类型转换
|
||||
fmt.Println(v.Int())
|
||||
fmt.Println(v.Uint())
|
||||
fmt.Println(v.Float64())
|
||||
|
||||
// slice转换
|
||||
fmt.Println(v.Ints())
|
||||
fmt.Println(v.Floats())
|
||||
fmt.Println(v.Strings())
|
||||
|
||||
// struct转换
|
||||
type Score struct {
|
||||
Value int
|
||||
}
|
||||
s := new(Score)
|
||||
v.Struct(s)
|
||||
fmt.Println(s)
|
||||
}
|
||||
79
.example/database/gdb/driver/driver/driver.go
Normal file
79
.example/database/gdb/driver/driver/driver.go
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package driver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
)
|
||||
|
||||
// MyDriver is a custom database driver, which is used for testing only.
|
||||
// For simplifying the unit testing case purpose, MyDriver struct inherits the mysql driver
|
||||
// gdb.DriverMysql and overwrites its functions DoQuery and DoExec.
|
||||
// So if there's any sql execution, it goes through MyDriver.DoQuery/MyDriver.DoExec firstly
|
||||
// and then gdb.DriverMysql.DoQuery/gdb.DriverMysql.DoExec.
|
||||
// You can call it sql "HOOK" or "HiJack" as your will.
|
||||
type MyDriver struct {
|
||||
*gdb.DriverMysql
|
||||
}
|
||||
|
||||
var (
|
||||
// customDriverName is my driver name, which is used for registering.
|
||||
customDriverName = "MyDriver"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// It here registers my custom driver in package initialization function "init".
|
||||
// You can later use this type in the database configuration.
|
||||
if err := gdb.Register(customDriverName, &MyDriver{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// New creates and returns a database object for mysql.
|
||||
// It implements the interface of gdb.Driver for extra database driver installation.
|
||||
func (d *MyDriver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error) {
|
||||
return &MyDriver{
|
||||
&gdb.DriverMysql{
|
||||
Core: core,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DoQuery commits the sql string and its arguments to underlying driver
|
||||
// through given link object and returns the execution result.
|
||||
func (d *MyDriver) DoQuery(link gdb.Link, sql string, args ...interface{}) (rows *sql.Rows, err error) {
|
||||
tsMilli := gtime.TimestampMilli()
|
||||
rows, err = d.DriverMysql.DoQuery(link, sql, args...)
|
||||
if _, err := d.DriverMysql.InsertIgnore("monitor", g.Map{
|
||||
"sql": gdb.FormatSqlWithArgs(sql, args),
|
||||
"cost": gtime.TimestampMilli() - tsMilli,
|
||||
"time": gtime.Now(),
|
||||
"error": err.Error(),
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DoExec commits the query string and its arguments to underlying driver
|
||||
// through given link object and returns the execution result.
|
||||
func (d *MyDriver) DoExec(link gdb.Link, sql string, args ...interface{}) (result sql.Result, err error) {
|
||||
tsMilli := gtime.TimestampMilli()
|
||||
result, err = d.DriverMysql.DoExec(link, sql, args...)
|
||||
if _, err := d.DriverMysql.InsertIgnore("monitor", g.Map{
|
||||
"sql": gdb.FormatSqlWithArgs(sql, args),
|
||||
"cost": gtime.TimestampMilli() - tsMilli,
|
||||
"time": gtime.Now(),
|
||||
"error": err.Error(),
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
1
.example/database/gdb/driver/main.go
Normal file
1
.example/database/gdb/driver/main.go
Normal file
@ -0,0 +1 @@
|
||||
package main
|
||||
3
.example/database/gdb/mssql/config.toml
Normal file
3
.example/database/gdb/mssql/config.toml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
[database]
|
||||
linkinfo = "mssql:user id=test;password=test1;server=122.152.202.91;port=1433;database=test;encrypt=disable"
|
||||
23
.example/database/gdb/mssql/gdb_all.go
Normal file
23
.example/database/gdb/mssql/gdb_all.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
type Table2 struct {
|
||||
Id string `orm:"id;pr" json:"id"` //ID
|
||||
Createtime gtime.Time `orm:"createtime" json:"createtime"` //创建时间
|
||||
Updatetime gtime.Time `orm:"updatetime" json:"updatetime"` //更新时间
|
||||
}
|
||||
var table2 Table2
|
||||
err := g.DB().Table("table2").Where("id=?", 1).Struct(&table2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(table2.Createtime)
|
||||
}
|
||||
575
.example/database/gdb/mssql/gdb_sqlserver.go
Normal file
575
.example/database/gdb/mssql/gdb_sqlserver.go
Normal file
@ -0,0 +1,575 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
//_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mssql数据库操作示例,不作为单元测试使用
|
||||
|
||||
var db gdb.DB
|
||||
|
||||
// 初始化配置及创建数据库
|
||||
func init() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "1433",
|
||||
User: "sa",
|
||||
Pass: "123456",
|
||||
Name: "test",
|
||||
Type: "mssql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/frame")
|
||||
//db = g.Database()
|
||||
|
||||
//gdb.SetConfig(gdb.ConfigNode {
|
||||
// Host : "127.0.0.1",
|
||||
// Port : 3306,
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
//})
|
||||
//db, _ = gdb.Instance()
|
||||
|
||||
//gdb.SetConfig(gdb.Config {
|
||||
// "default" : gdb.ConfigGroup {
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.1",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.2",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.3",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.4",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
//db, _ = gdb.Instance()
|
||||
}
|
||||
|
||||
// 创建测试数据库
|
||||
func create() error {
|
||||
fmt.Println("drop table aa_user:")
|
||||
_, err := db.Exec("drop table aa_user")
|
||||
if err != nil {
|
||||
fmt.Println("drop table aa_user error.", err)
|
||||
}
|
||||
|
||||
s := `
|
||||
CREATE TABLE aa_user (
|
||||
id int not null,
|
||||
name VARCHAR(60),
|
||||
age int,
|
||||
addr varchar(60),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
`
|
||||
fmt.Println("create table aa_user:")
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create table error.", err)
|
||||
return err
|
||||
}
|
||||
|
||||
/*_, err = db.Exec("drop sequence id_seq")
|
||||
if err != nil {
|
||||
fmt.Println("drop sequence id_seq", err)
|
||||
}
|
||||
|
||||
fmt.Println("create sequence id_seq")
|
||||
_, err = db.Exec("create sequence id_seq increment by 1 start with 1 maxvalue 9999999999 cycle cache 10")
|
||||
if err != nil {
|
||||
fmt.Println("create sequence id_seq error.", err)
|
||||
return err
|
||||
}
|
||||
|
||||
s = `
|
||||
CREATE TRIGGER id_trigger before insert on aa_user for each row
|
||||
begin
|
||||
select id_seq.nextval into :new.id from dual;
|
||||
end;
|
||||
`
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create trigger error.", err)
|
||||
return err
|
||||
}*/
|
||||
|
||||
_, err = db.Exec("drop table user_detail")
|
||||
if err != nil {
|
||||
fmt.Println("drop table user_detail", err)
|
||||
}
|
||||
|
||||
s = `
|
||||
CREATE TABLE user_detail (
|
||||
id int not null,
|
||||
site VARCHAR(255),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
`
|
||||
fmt.Println("create table user_detail:")
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create table user_detail error.", err)
|
||||
return err
|
||||
}
|
||||
fmt.Println("create table success.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 数据写入
|
||||
func insert(id int) {
|
||||
fmt.Println("insert:")
|
||||
r, err := db.Insert("aa_user", gdb.Map{
|
||||
"id": id,
|
||||
"name": "john",
|
||||
"age": id,
|
||||
})
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
if err == nil {
|
||||
r, err = db.Insert("user_detail", gdb.Map{
|
||||
"id": id,
|
||||
"site": "http://johng.cn",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Printf("id: %d\n", id)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 基本sql查询
|
||||
func query() {
|
||||
fmt.Println("query:")
|
||||
list, err := db.GetAll("select * from aa_user where 1=1")
|
||||
if err == nil {
|
||||
fmt.Println(list)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
list, err = db.Table("aa_user").OrderBy("id").Limit(0, 5).Select()
|
||||
if err == nil {
|
||||
fmt.Println(list)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// replace into
|
||||
func replace() {
|
||||
fmt.Println("replace:")
|
||||
r, err := db.Save("aa_user", gdb.Map{
|
||||
"id": 1,
|
||||
"name": "john",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据保存
|
||||
func save() {
|
||||
fmt.Println("save:")
|
||||
r, err := db.Save("aa_user", gdb.Map{
|
||||
"id": 1,
|
||||
"name": "john",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 批量写入
|
||||
func batchInsert() {
|
||||
fmt.Println("batchInsert:")
|
||||
_, err := db.BatchInsert("aa_user", gdb.List{
|
||||
{"id": 11, "name": "batchInsert_john_1", "age": 11},
|
||||
{"id": 12, "name": "batchInsert_john_2", "age": 12},
|
||||
{"id": 13, "name": "batchInsert_john_3", "age": 13},
|
||||
{"id": 14, "name": "batchInsert_john_4", "age": 14},
|
||||
}, 10)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update1() {
|
||||
fmt.Println("update1:")
|
||||
r, err := db.Update("aa_user", gdb.Map{"name": "john1", "age": 1}, "id=?", 1)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update2() {
|
||||
fmt.Println("update2:")
|
||||
r, err := db.Update("aa_user", gdb.Map{"name": "john6", "age": 6}, "id=?", 2)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update3() {
|
||||
fmt.Println("update3:")
|
||||
r, err := db.Update("aa_user", "name=?", "id=?", "john2", 3)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作1
|
||||
func linkopSelect1() {
|
||||
fmt.Println("linkopSelect1:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("u.*, ud.site").Where("u.id > ?", 1).Limit(3, 5).Select()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作2
|
||||
func linkopSelect2() {
|
||||
fmt.Println("linkopSelect2:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("u.*,ud.site").Where("u.id=?", 1).One()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作3
|
||||
func linkopSelect3() {
|
||||
fmt.Println("linkopSelect3:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("ud.site").Where("u.id=?", 1).Value()
|
||||
if err == nil {
|
||||
fmt.Println(r.String())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询数量1
|
||||
func linkopCount1() {
|
||||
fmt.Println("linkopCount1:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Where("name like ?", "john").Count()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 错误操作
|
||||
func linkopUpdate1() {
|
||||
fmt.Println("linkopUpdate1:")
|
||||
r, err := db.Table("henghe_setting").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println("error", err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 通过Map指针方式传参方式
|
||||
func linkopUpdate2() {
|
||||
fmt.Println("linkopUpdate2:")
|
||||
r, err := db.Table("aa_user").Data(gdb.Map{"name": "john2"}).Where("name=?", "john").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 通过字符串方式传参
|
||||
func linkopUpdate3() {
|
||||
fmt.Println("linkopUpdate3:")
|
||||
r, err := db.Table("aa_user").Data("name='john3'").Where("name=?", "john2").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// Where条件使用Map
|
||||
func linkopUpdate4() {
|
||||
fmt.Println("linkopUpdate4:")
|
||||
r, err := db.Table("aa_user").Data(gdb.Map{"name": "john11111"}).Where(g.Map{"id": 1}).Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量写入
|
||||
func linkopBatchInsert1() {
|
||||
fmt.Println("linkopBatchInsert1:")
|
||||
r, err := db.Table("aa_user").Filter().Data(gdb.List{
|
||||
{"id": 21, "name": "linkopBatchInsert1_john_1", "amt": 21.21, "tt": "haha"},
|
||||
{"id": 22, "name": "linkopBatchInsert1_john_2", "amt": 22.22, "cc": "hahacc"},
|
||||
{"id": 23, "name": "linkopBatchInsert1_john_3", "amt": 23.23, "bb": "hahabb"},
|
||||
{"id": 24, "name": "linkopBatchInsert1_john_4", "amt": 24.24, "aa": "hahaaa"},
|
||||
}).Insert()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量写入,指定每批次写入的条数
|
||||
func linkopBatchInsert2() {
|
||||
fmt.Println("linkopBatchInsert2:")
|
||||
r, err := db.Table("aa_user").Data(gdb.List{
|
||||
{"id": 25, "name": "linkopBatchInsert2john_1"},
|
||||
{"id": 26, "name": "linkopBatchInsert2john_2"},
|
||||
{"id": 27, "name": "linkopBatchInsert2john_3"},
|
||||
{"id": 28, "name": "linkopBatchInsert2john_4"},
|
||||
}).Batch(2).Insert()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量保存
|
||||
func linkopBatchSave() {
|
||||
fmt.Println("linkopBatchSave:")
|
||||
r, err := db.Table("aa_user").Data(gdb.List{
|
||||
{"id": 1, "name": "john_1"},
|
||||
{"id": 2, "name": "john_2"},
|
||||
{"id": 3, "name": "john_3"},
|
||||
{"id": 4, "name": "john_4"},
|
||||
}).Save()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 事务操作示例1
|
||||
func transaction1() {
|
||||
fmt.Println("transaction1:")
|
||||
if tx, err := db.Begin(); err == nil {
|
||||
r, err := tx.Insert("aa_user", gdb.Map{
|
||||
"id": 30,
|
||||
"name": "transaction1",
|
||||
})
|
||||
tx.Rollback()
|
||||
fmt.Println(r, err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 事务操作示例2
|
||||
func transaction2() {
|
||||
fmt.Println("transaction2:")
|
||||
if tx, err := db.Begin(); err == nil {
|
||||
r, err := tx.Table("user_detail").Data(gdb.Map{"id": 6, "site": "www.baidu.com哈哈哈*?''\"~!@#$%^&*()"}).Insert()
|
||||
tx.Commit()
|
||||
fmt.Println(r, err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 主从io复用测试,在mysql中使用 show full processlist 查看链接信息
|
||||
func keepPing() {
|
||||
fmt.Println("keepPing:")
|
||||
for i := 0; i < 30; i++ {
|
||||
fmt.Println("ping...", i)
|
||||
err := db.PingMaster()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = db.PingSlave()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
// like语句查询
|
||||
func likeQuery() {
|
||||
fmt.Println("likeQuery:")
|
||||
if r, err := db.Table("aa_user").Where("name like ?", "%john%").Select(); err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// mapToStruct
|
||||
func mapToStruct() {
|
||||
type User struct {
|
||||
Id int
|
||||
Name string
|
||||
Age int
|
||||
Addr string
|
||||
}
|
||||
fmt.Println("mapToStruct:")
|
||||
if r, err := db.Table("aa_user").Where("id=?", 1).One(); err == nil {
|
||||
u := User{}
|
||||
if err := r.ToStruct(&u); err == nil {
|
||||
fmt.Println(r)
|
||||
fmt.Println(u)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// getQueriedSqls
|
||||
func getQueriedSqls() {
|
||||
for k, v := range db.GetQueriedSqls() {
|
||||
fmt.Println(k, ":")
|
||||
fmt.Println("Sql :", v.Sql)
|
||||
fmt.Println("Args :", v.Args)
|
||||
fmt.Println("Error:", v.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
db.PingMaster()
|
||||
db.SetDebug(true)
|
||||
/*err := create()
|
||||
if err != nil {
|
||||
return
|
||||
}*/
|
||||
|
||||
//test1
|
||||
/*for i := 1; i < 5; i++ {
|
||||
insert(i)
|
||||
}*/
|
||||
//insert(2)
|
||||
//query()
|
||||
|
||||
//batchInsert()
|
||||
//query()
|
||||
|
||||
//replace()
|
||||
//save()
|
||||
|
||||
/*update1()
|
||||
update2()
|
||||
update3()
|
||||
*/
|
||||
|
||||
/*linkopSelect1()
|
||||
linkopSelect2()
|
||||
linkopSelect3()
|
||||
linkopCount1()
|
||||
*/
|
||||
|
||||
/*linkopUpdate1()
|
||||
linkopUpdate2()
|
||||
linkopUpdate3()
|
||||
linkopUpdate4()
|
||||
*/
|
||||
|
||||
linkopBatchInsert1()
|
||||
query()
|
||||
//linkopBatchInsert2()
|
||||
|
||||
//transaction1()
|
||||
//transaction2()
|
||||
//
|
||||
//keepPing()
|
||||
//likeQuery()
|
||||
//mapToStruct()
|
||||
//getQueriedSqls()
|
||||
}
|
||||
16
.example/database/gdb/mysql/config.toml
Normal file
16
.example/database/gdb/mysql/config.toml
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# MySQL数据库配置
|
||||
[database]
|
||||
# debug = true
|
||||
link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test?parseTime=true&loc=Local"
|
||||
|
||||
#[database]
|
||||
# [[database.default]]
|
||||
# type = "mysql"
|
||||
# link = "root:12345678@tcp(127.0.0.1:3306)/test?parseTime=true&loc=Local"
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
37
.example/database/gdb/mysql/config/gdb.go
Normal file
37
.example/database/gdb/mysql/config/gdb.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var db gdb.DB
|
||||
|
||||
func init() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "3306",
|
||||
User: "root",
|
||||
Pass: "12345678",
|
||||
Name: "test",
|
||||
Type: "mysql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
MaxOpenConnCount: 100,
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
}
|
||||
|
||||
func main() {
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 100000; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
time.Sleep(10 * time.Second)
|
||||
db.Table("user").Where("id=1").All()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
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"
|
||||
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").Order("id asc").All()
|
||||
if e != nil {
|
||||
fmt.Println(e)
|
||||
}
|
||||
if r != nil {
|
||||
fmt.Println(r.List())
|
||||
}
|
||||
}
|
||||
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()
|
||||
}
|
||||
51
.example/database/gdb/mysql/gdb_binary.go
Normal file
51
.example/database/gdb/mysql/gdb_binary.go
Normal file
@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/crypto/gaes"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "3306",
|
||||
User: "root",
|
||||
Pass: "123456",
|
||||
Name: "test",
|
||||
Type: "mysql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db, err := gdb.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
key := "0123456789123456"
|
||||
|
||||
name := "john"
|
||||
encryptedName, err := gaes.Encrypt([]byte(name), []byte(key))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
// 写入
|
||||
r, err := db.Table("user").Data(g.Map{
|
||||
"uid": 1,
|
||||
"name": encryptedName,
|
||||
}).Save()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(r.RowsAffected())
|
||||
|
||||
// 查询
|
||||
one, err := db.Table("user").Where("name=?", encryptedName).One()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(one.ToMap())
|
||||
}
|
||||
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())
|
||||
}
|
||||
}
|
||||
38
.example/database/gdb/mysql/gdb_cache.go
Normal file
38
.example/database/gdb/mysql/gdb_cache.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/util/gutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "3306",
|
||||
User: "root",
|
||||
Pass: "123456",
|
||||
Name: "test",
|
||||
Type: "mysql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db, err := gdb.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
// 执行2次查询并将查询结果缓存3秒,并可执行缓存名称(可选)
|
||||
for i := 0; i < 2; i++ {
|
||||
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
||||
gutil.Dump(r.ToMap())
|
||||
}
|
||||
|
||||
// 执行更新操作,并清理指定名称的查询缓存
|
||||
db.Table("user").Cache(-1, "vip-user").Data(gdb.Map{"name": "smith"}).Where("uid=?", 1).Update()
|
||||
|
||||
// 再次执行查询,启用查询缓存特性
|
||||
r, _ := db.Table("user").Cache(3, "vip-user").Where("uid=?", 1).One()
|
||||
gutil.Dump(r.ToMap())
|
||||
}
|
||||
24
.example/database/gdb/mysql/gdb_complecated.go
Normal file
24
.example/database/gdb/mysql/gdb_complecated.go
Normal 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)
|
||||
|
||||
}
|
||||
16
.example/database/gdb/mysql/gdb_config.go
Normal file
16
.example/database/gdb/mysql/gdb_config.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
30
.example/database/gdb/mysql/gdb_datetime.go
Normal file
30
.example/database/gdb/mysql/gdb_datetime.go
Normal file
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.Database()
|
||||
db.SetDebug(true)
|
||||
|
||||
//r, err := db.Table("user").Data("create_time", gtime.Now().String()).Insert()
|
||||
//if err == nil {
|
||||
// fmt.Println(r.LastInsertId())
|
||||
//} else {
|
||||
// panic(err)
|
||||
//}
|
||||
|
||||
r, err := db.Table("user").Data(g.Map{
|
||||
"name": "john",
|
||||
"create_time": gtime.Now().String(),
|
||||
}).Insert()
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
37
.example/database/gdb/mysql/gdb_debug1.go
Normal file
37
.example/database/gdb/mysql/gdb_debug1.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "3306",
|
||||
User: "root",
|
||||
Pass: "12345678",
|
||||
Name: "test",
|
||||
Type: "mysql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db, err := gdb.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//db.SetDebug(false)
|
||||
|
||||
glog.SetPath("/tmp")
|
||||
|
||||
// 执行3条SQL查询
|
||||
for i := 1; i <= 3; i++ {
|
||||
db.Table("user").Where("uid=?", i).One()
|
||||
}
|
||||
// 构造一条错误查询
|
||||
db.Table("user").Where("no_such_field=?", "just_test").One()
|
||||
|
||||
db.Table("user").Data(g.Map{"name": "smith"}).Where("uid=?", 1).Save()
|
||||
|
||||
}
|
||||
18
.example/database/gdb/mysql/gdb_debug2.go
Normal file
18
.example/database/gdb/mysql/gdb_debug2.go
Normal file
@ -0,0 +1,18 @@
|
||||
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()
|
||||
}
|
||||
31
.example/database/gdb/mysql/gdb_insert.go
Normal file
31
.example/database/gdb/mysql/gdb_insert.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//db := g.DB()
|
||||
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
LinkInfo: "root:12345678@tcp(127.0.0.1:3306)/test?parseTime=true&loc=Local",
|
||||
Type: "mysql",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db, _ := gdb.New()
|
||||
|
||||
db.SetDebug(true)
|
||||
|
||||
type User struct {
|
||||
CreateTime time.Time `orm:"create_time"`
|
||||
}
|
||||
r, e := db.Table("user").Data(User{CreateTime: time.Now()}).Insert()
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if r != nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
37
.example/database/gdb/mysql/gdb_json_xml.go
Normal file
37
.example/database/gdb/mysql/gdb_json_xml.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "127.0.0.1",
|
||||
Port: "3306",
|
||||
User: "root",
|
||||
Pass: "12345678",
|
||||
Name: "test",
|
||||
Type: "mysql",
|
||||
Role: "master",
|
||||
Charset: "utf8",
|
||||
})
|
||||
db := g.DB()
|
||||
one, err := db.Table("user").Where("id=?", 1).One()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 使用内置方法转换为json/xml
|
||||
fmt.Println(one.ToJson())
|
||||
fmt.Println(one.ToXml())
|
||||
|
||||
// 自定义方法方法转换为json/xml
|
||||
jsonContent, _ := gparser.VarToJson(one.ToMap())
|
||||
fmt.Println(string(jsonContent))
|
||||
xmlContent, _ := gparser.VarToXml(one.ToMap())
|
||||
fmt.Println(string(xmlContent))
|
||||
}
|
||||
25
.example/database/gdb/mysql/gdb_pool.go
Normal file
25
.example/database/gdb/mysql/gdb_pool.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetMaxIdleConnCount(10)
|
||||
db.SetMaxOpenConnCount(10)
|
||||
db.SetMaxConnLifetime(time.Minute)
|
||||
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
for {
|
||||
for i := 0; i < 10; i++ {
|
||||
go db.Table("user").All()
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
}
|
||||
18
.example/database/gdb/mysql/gdb_reconnect.go
Normal file
18
.example/database/gdb/mysql/gdb_reconnect.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
for {
|
||||
r, err := db.Table("user").All()
|
||||
fmt.Println(err)
|
||||
fmt.Println(r)
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
23
.example/database/gdb/mysql/gdb_struct.go
Normal file
23
.example/database/gdb/mysql/gdb_struct.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
type User struct {
|
||||
Uid int
|
||||
Name string
|
||||
}
|
||||
user := (*User)(nil)
|
||||
fmt.Println(user)
|
||||
err := db.Table("test").Where("id=1").Struct(&user)
|
||||
fmt.Println(err)
|
||||
fmt.Println(user)
|
||||
}
|
||||
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)
|
||||
}
|
||||
17
.example/database/gdb/mysql/gdb_update_union.go
Normal file
17
.example/database/gdb/mysql/gdb_update_union.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
result, err := db.Table("pw_passageway m,pw_template t").Data("t.status", 99).Where("m.templateId=t.id AND m.status = 0").Update()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(result.RowsAffected())
|
||||
}
|
||||
12
.example/database/gdb/mysql/gdb_value.go
Normal file
12
.example/database/gdb/mysql/gdb_value.go
Normal file
@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
db.SetDebug(true)
|
||||
|
||||
db.Table("user").Fields("DISTINCT id,nickname").Filter().All()
|
||||
}
|
||||
34
.example/database/gdb/mysql/issue364.go
Normal file
34
.example/database/gdb/mysql/issue364.go
Normal 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()
|
||||
}
|
||||
575
.example/database/gdb/oracle/gdb.go
Normal file
575
.example/database/gdb/oracle/gdb.go
Normal file
@ -0,0 +1,575 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
//_ "github.com/mattn/go-oci8"
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
// 本文件用于gf框架的mysql数据库操作示例,不作为单元测试使用
|
||||
|
||||
var db gdb.DB
|
||||
|
||||
// 初始化配置及创建数据库
|
||||
func init() {
|
||||
gdb.AddDefaultConfigNode(gdb.ConfigNode{
|
||||
Host: "192.168.146.0",
|
||||
Port: "1521",
|
||||
User: "test",
|
||||
Pass: "test",
|
||||
Name: "orcl",
|
||||
Type: "oracle",
|
||||
Role: "master",
|
||||
})
|
||||
db, _ = gdb.New()
|
||||
|
||||
//gins.Config().SetPath("/home/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/frame")
|
||||
//db = g.Database()
|
||||
|
||||
//gdb.SetConfig(gdb.ConfigNode {
|
||||
// Host : "127.0.0.1",
|
||||
// Port : 3306,
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
//})
|
||||
//db, _ = gdb.Instance()
|
||||
|
||||
//gdb.SetConfig(gdb.Config {
|
||||
// "default" : gdb.ConfigGroup {
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.1",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.2",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.3",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// gdb.ConfigNode {
|
||||
// Host : "127.0.0.4",
|
||||
// Port : "3306",
|
||||
// User : "root",
|
||||
// Pass : "123456",
|
||||
// Name : "test",
|
||||
// Type : "mysql",
|
||||
// Role : "master",
|
||||
// Weight : 100,
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
//db, _ = gdb.Instance()
|
||||
}
|
||||
|
||||
// 创建测试数据库
|
||||
func create() error {
|
||||
fmt.Println("drop table aa_user:")
|
||||
_, err := db.Exec("drop table aa_user")
|
||||
if err != nil {
|
||||
fmt.Println("drop table aa_user error.", err)
|
||||
}
|
||||
|
||||
s := `
|
||||
CREATE TABLE aa_user (
|
||||
id number(10) not null,
|
||||
name VARCHAR2(45),
|
||||
age number(8),
|
||||
addr varchar2(60),
|
||||
amt number(12,2),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
`
|
||||
fmt.Println("create table aa_user:")
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create table error.", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = db.Exec("drop sequence id_seq")
|
||||
if err != nil {
|
||||
fmt.Println("drop sequence id_seq", err)
|
||||
}
|
||||
|
||||
/*fmt.Println("create sequence id_seq")
|
||||
_, err = db.Exec("create sequence id_seq increment by 1 start with 1 maxvalue 9999999999 cycle cache 10")
|
||||
if err != nil {
|
||||
fmt.Println("create sequence id_seq error.", err)
|
||||
return err
|
||||
}
|
||||
|
||||
s = `
|
||||
CREATE TRIGGER id_trigger before insert on aa_user for each row
|
||||
begin
|
||||
select id_seq.nextval into :new.id from dual;
|
||||
end;
|
||||
`
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create trigger error.", err)
|
||||
return err
|
||||
}*/
|
||||
|
||||
_, err = db.Exec("drop table user_detail")
|
||||
if err != nil {
|
||||
fmt.Println("drop table user_detail", err)
|
||||
}
|
||||
|
||||
s = `
|
||||
CREATE TABLE user_detail (
|
||||
id number(10) not null,
|
||||
site VARCHAR2(255),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
`
|
||||
fmt.Println("create table user_detail:")
|
||||
_, err = db.Exec(s)
|
||||
if err != nil {
|
||||
fmt.Println("create table user_detail error.", err)
|
||||
return err
|
||||
}
|
||||
fmt.Println("create table success.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 数据写入
|
||||
func insert(id int) {
|
||||
fmt.Println("insert:")
|
||||
|
||||
r, err := db.Insert("aa_user", gdb.Map{
|
||||
"id": id,
|
||||
"name": "john",
|
||||
"age": id,
|
||||
})
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
if err == nil {
|
||||
r, err = db.Insert("user_detail", gdb.Map{
|
||||
"id": id,
|
||||
"site": "http://johng.cn",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Printf("id: %d\n", id)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 基本sql查询
|
||||
func query() {
|
||||
fmt.Println("query:")
|
||||
list, err := db.GetAll("select * from aa_user")
|
||||
if err == nil {
|
||||
fmt.Println(list)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
list, err = db.Table("aa_user").OrderBy("id").Limit(0, 2).Select()
|
||||
if err == nil {
|
||||
fmt.Println(list)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// replace into
|
||||
func replace() {
|
||||
fmt.Println("replace:")
|
||||
r, err := db.Save("aa_user", gdb.Map{
|
||||
"id": 1,
|
||||
"name": "john",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据保存
|
||||
func save() {
|
||||
fmt.Println("save:")
|
||||
r, err := db.Save("aa_user", gdb.Map{
|
||||
"id": 1,
|
||||
"name": "john",
|
||||
})
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 批量写入
|
||||
func batchInsert() {
|
||||
fmt.Println("batchInsert:")
|
||||
_, err := db.BatchInsert("aa_user", gdb.List{
|
||||
{"id": 11, "name": "batchInsert_john_1", "age": 11, "amt": 11.11},
|
||||
{"id": 12, "name": "batchInsert_john_2", "age": 12, "amt": 12.12},
|
||||
{"id": 13, "name": "batchInsert_john_3", "age": 13, "amt": 13.13},
|
||||
{"id": 14, "name": "batchInsert_john_4", "age": 14, "amt": 14.14},
|
||||
}, 10)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update1() {
|
||||
fmt.Println("update1:")
|
||||
r, err := db.Update("aa_user", gdb.Map{"name": "john1", "age": 1}, "id=?", 1)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update2() {
|
||||
fmt.Println("update2:")
|
||||
r, err := db.Update("aa_user", gdb.Map{"name": "john6", "age": 6}, "id=?", 2)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
func update3() {
|
||||
fmt.Println("update3:")
|
||||
r, err := db.Update("aa_user", "name=?", "id=?", "john2", 3)
|
||||
if err == nil {
|
||||
fmt.Println(r.LastInsertId())
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作1
|
||||
func linkopSelect1() {
|
||||
fmt.Println("linkopSelect1:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("u.*, ud.site").Where("u.id > ?", 1).Limit(0, 2).Select()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作2
|
||||
func linkopSelect2() {
|
||||
fmt.Println("linkopSelect2:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("u.*,ud.site").Where("u.id=?", 1).One()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询操作3
|
||||
func linkopSelect3() {
|
||||
fmt.Println("linkopSelect3:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Fields("ud.site").Where("u.id=?", 1).Value()
|
||||
if err == nil {
|
||||
fmt.Println(r.String())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式查询数量1
|
||||
func linkopCount1() {
|
||||
fmt.Println("linkopCount1:")
|
||||
r, err := db.Table("aa_user u").LeftJoin("user_detail ud", "u.id=ud.id").Where("name like ?", "john").Count()
|
||||
if err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 错误操作
|
||||
func linkopUpdate1() {
|
||||
fmt.Println("linkopUpdate1:")
|
||||
r, err := db.Table("henghe_setting").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println("error", err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 通过Map指针方式传参方式
|
||||
func linkopUpdate2() {
|
||||
fmt.Println("linkopUpdate2:")
|
||||
r, err := db.Table("aa_user").Data(gdb.Map{"name": "john2"}).Where("name=?", "john").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 通过字符串方式传参
|
||||
func linkopUpdate3() {
|
||||
fmt.Println("linkopUpdate3:")
|
||||
r, err := db.Table("aa_user").Data("name='john3'").Where("name=?", "john2").Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// Where条件使用Map
|
||||
func linkopUpdate4() {
|
||||
fmt.Println("linkopUpdate4:")
|
||||
r, err := db.Table("aa_user").Data(gdb.Map{"name": "john11111"}).Where(g.Map{"id": 1}).Update()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量写入
|
||||
func linkopBatchInsert1() {
|
||||
fmt.Println("linkopBatchInsert1:")
|
||||
r, err := db.Table("aa_user").Filter().Data(gdb.List{
|
||||
{"id": 21, "name": "linkopBatchInsert1_john_1", "amt": 21.21, "tt": "haha"},
|
||||
{"id": 22, "name": "linkopBatchInsert1_john_2", "amt": 22.22, "cc": "hahacc"},
|
||||
{"id": 23, "name": "linkopBatchInsert1_john_3", "amt": 23.23, "bb": "hahabb"},
|
||||
{"id": 24, "name": "linkopBatchInsert1_john_4", "amt": 24.24, "aa": "hahaaa"},
|
||||
}).Insert()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量写入,指定每批次写入的条数
|
||||
func linkopBatchInsert2() {
|
||||
fmt.Println("linkopBatchInsert2:")
|
||||
r, err := db.Table("aa_user").Data(gdb.List{
|
||||
{"id": 25, "name": "linkopBatchInsert2john_1"},
|
||||
{"id": 26, "name": "linkopBatchInsert2john_2"},
|
||||
{"id": 27, "name": "linkopBatchInsert2john_3"},
|
||||
{"id": 28, "name": "linkopBatchInsert2john_4"},
|
||||
}).Batch(2).Insert()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 链式批量保存
|
||||
func linkopBatchSave() {
|
||||
fmt.Println("linkopBatchSave:")
|
||||
r, err := db.Table("aa_user").Data(gdb.List{
|
||||
{"id": 1, "name": "john_1"},
|
||||
{"id": 2, "name": "john_2"},
|
||||
{"id": 3, "name": "john_3"},
|
||||
{"id": 4, "name": "john_4"},
|
||||
}).Save()
|
||||
if err == nil {
|
||||
fmt.Println(r.RowsAffected())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 事务操作示例1
|
||||
func transaction1() {
|
||||
fmt.Println("transaction1:")
|
||||
if tx, err := db.Begin(); err == nil {
|
||||
r, err := tx.Insert("aa_user", gdb.Map{
|
||||
"id": 30,
|
||||
"name": "transaction1",
|
||||
})
|
||||
tx.Rollback()
|
||||
fmt.Println(r, err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 事务操作示例2
|
||||
func transaction2() {
|
||||
fmt.Println("transaction2:")
|
||||
if tx, err := db.Begin(); err == nil {
|
||||
r, err := tx.Table("user_detail").Data(gdb.Map{"id": 5, "site": "www.baidu.com哈哈哈*?~!@#$%^&*()"}).Insert()
|
||||
tx.Commit()
|
||||
fmt.Println(r, err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 主从io复用测试,在mysql中使用 show full processlist 查看链接信息
|
||||
func keepPing() {
|
||||
fmt.Println("keepPing:")
|
||||
for i := 0; i < 30; i++ {
|
||||
fmt.Println("ping...", i)
|
||||
err := db.PingMaster()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = db.PingSlave()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
// like语句查询
|
||||
func likeQuery() {
|
||||
fmt.Println("likeQuery:")
|
||||
if r, err := db.Table("aa_user").Where("name like ?", "%john%").Select(); err == nil {
|
||||
fmt.Println(r)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// mapToStruct
|
||||
func mapToStruct() {
|
||||
type User struct {
|
||||
Id int
|
||||
Name string
|
||||
Age int
|
||||
Addr string
|
||||
}
|
||||
fmt.Println("mapToStruct:")
|
||||
if r, err := db.Table("aa_user").Where("id=?", 1).One(); err == nil {
|
||||
u := User{}
|
||||
if err := r.ToStruct(&u); err == nil {
|
||||
fmt.Println(r)
|
||||
fmt.Println(u)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// getQueriedSqls
|
||||
func getQueriedSqls() {
|
||||
for k, v := range db.GetQueriedSqls() {
|
||||
fmt.Println(k, ":")
|
||||
fmt.Println("Sql :", v.Sql)
|
||||
fmt.Println("Args :", v.Args)
|
||||
fmt.Println("Error:", v.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
db.PingMaster()
|
||||
db.SetDebug(true)
|
||||
/*err := create()
|
||||
if err != nil {
|
||||
return
|
||||
}*/
|
||||
|
||||
//test1
|
||||
/*for i := 1; i < 5; i++ {
|
||||
insert(i)
|
||||
}
|
||||
query()
|
||||
*/
|
||||
|
||||
//batchInsert()
|
||||
//query()
|
||||
|
||||
//replace()
|
||||
//save()
|
||||
|
||||
//update1()
|
||||
//update2()
|
||||
//update3()
|
||||
|
||||
/*linkopSelect1()
|
||||
linkopSelect2()
|
||||
linkopSelect3()
|
||||
linkopCount1()
|
||||
*/
|
||||
|
||||
/*linkopUpdate1()
|
||||
linkopUpdate2()
|
||||
linkopUpdate3()
|
||||
linkopUpdate4()
|
||||
*/
|
||||
|
||||
linkopBatchInsert1()
|
||||
query()
|
||||
//linkopBatchInsert2()
|
||||
|
||||
//transaction1()
|
||||
//transaction2()
|
||||
//
|
||||
//keepPing()
|
||||
//likeQuery()
|
||||
//mapToStruct()
|
||||
//getQueriedSqls()
|
||||
}
|
||||
47
.example/database/gdb/sqlite/sqlite.go
Normal file
47
.example/database/gdb/sqlite/sqlite.go
Normal 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)
|
||||
}
|
||||
}
|
||||
20
.example/database/gredis/gredis.go
Normal file
20
.example/database/gredis/gredis.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/database/gredis"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
// 使用原生gredis.New操作redis,但是注意需要自己调用Close方法关闭redis链接池
|
||||
func main() {
|
||||
redis := gredis.New(gredis.Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
})
|
||||
defer redis.Close()
|
||||
redis.Do("SET", "k", "v")
|
||||
v, _ := redis.Do("GET", "k")
|
||||
fmt.Println(gconv.String(v))
|
||||
}
|
||||
15
.example/database/gredis/gredis2.go
Normal file
15
.example/database/gredis/gredis2.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
// 使用框架封装的g.Redis()方法获得redis操作对象单例,不需要开发者显示调用Close方法
|
||||
func main() {
|
||||
g.Redis().Do("SET", "k", "v")
|
||||
v, _ := g.Redis().Do("GET", "k")
|
||||
fmt.Println(gconv.String(v))
|
||||
}
|
||||
16
.example/database/gredis/gredis_conn_do.go
Normal file
16
.example/database/gredis/gredis_conn_do.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
conn.Do("SET", "k", "v")
|
||||
v, _ := conn.Do("GET", "k")
|
||||
fmt.Println(gconv.String(v))
|
||||
}
|
||||
17
.example/database/gredis/gredis_conn_do_var.go
Normal file
17
.example/database/gredis/gredis_conn_do_var.go
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
if _, err := conn.Do("SET", "k", "v"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v, _ := conn.DoVar("GET", "k")
|
||||
fmt.Println(v.String())
|
||||
}
|
||||
21
.example/database/gredis/gredis_conn_send.go
Normal file
21
.example/database/gredis/gredis_conn_send.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
conn.Send("SET", "foo", "bar")
|
||||
conn.Send("GET", "foo")
|
||||
conn.Flush()
|
||||
// reply from SET
|
||||
conn.Receive()
|
||||
// reply from GET
|
||||
v, _ := conn.Receive()
|
||||
fmt.Println(gconv.String(v))
|
||||
}
|
||||
20
.example/database/gredis/gredis_conn_send_var.go
Normal file
20
.example/database/gredis/gredis_conn_send_var.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
conn.Send("SET", "foo", "bar")
|
||||
conn.Send("GET", "foo")
|
||||
conn.Flush()
|
||||
// reply from SET
|
||||
conn.Receive()
|
||||
// reply from GET
|
||||
v, _ := conn.ReceiveVar()
|
||||
fmt.Println(v.String())
|
||||
}
|
||||
24
.example/database/gredis/gredis_conn_subscribe.go
Normal file
24
.example/database/gredis/gredis_conn_subscribe.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
_, err := conn.Do("SUBSCRIBE", "channel")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for {
|
||||
reply, err := conn.Receive()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(gconv.Strings(reply))
|
||||
}
|
||||
}
|
||||
23
.example/database/gredis/gredis_conn_subscribe_var.go
Normal file
23
.example/database/gredis/gredis_conn_subscribe_var.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn := g.Redis().Conn()
|
||||
defer conn.Close()
|
||||
_, err := conn.Do("SUBSCRIBE", "channel")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for {
|
||||
reply, err := conn.ReceiveVar()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(reply.Strings())
|
||||
}
|
||||
}
|
||||
12
.example/debug/gdebug/gdebug.go
Normal file
12
.example/debug/gdebug/gdebug.go
Normal file
@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/debug/gdebug"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gdebug.PrintStack()
|
||||
fmt.Println(gdebug.CallerPackage())
|
||||
fmt.Println(gdebug.CallerFunction())
|
||||
}
|
||||
10
.example/debug/gdebug/gdebug_info.go
Normal file
10
.example/debug/gdebug/gdebug_info.go
Normal file
@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/debug/gdebug"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(gdebug.BuildInfo())
|
||||
}
|
||||
16
.example/encoding/gbase64/gbase64.go
Normal file
16
.example/encoding/gbase64/gbase64.go
Normal file
@ -0,0 +1,16 @@
|
||||
package gbase64
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbase64"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := "john"
|
||||
b := gbase64.Encode(s)
|
||||
c, e := gbase64.Decode(b)
|
||||
fmt.Println(b)
|
||||
fmt.Println(c)
|
||||
fmt.Println(e)
|
||||
}
|
||||
55
.example/encoding/gbinary/binary.go
Normal file
55
.example/encoding/gbinary/binary.go
Normal file
@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 使用gbinary.Encoded对基本数据类型进行二进制打包
|
||||
fmt.Println(gbinary.Encode(18, 300, 1.01))
|
||||
|
||||
// 使用gbinary.Decode对整形二进制解包,注意第二个及其后参数为字长确定的整形变量的指针地址,字长确定的类型,
|
||||
// 例如:int8/16/32/64、uint8/16/32/64、float32/64
|
||||
// 这里的1.01默认为float64类型(64位系统下)
|
||||
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 {
|
||||
fmt.Println(i1, i2, f3)
|
||||
}
|
||||
|
||||
// 编码/解析 int,自动识别变量长度
|
||||
fmt.Println(gbinary.DecodeToInt(gbinary.EncodeInt(1)))
|
||||
fmt.Println(gbinary.DecodeToInt(gbinary.EncodeInt(300)))
|
||||
fmt.Println(gbinary.DecodeToInt(gbinary.EncodeInt(70000)))
|
||||
fmt.Println(gbinary.DecodeToInt(gbinary.EncodeInt(2000000000)))
|
||||
fmt.Println(gbinary.DecodeToInt(gbinary.EncodeInt(500000000000)))
|
||||
|
||||
// 编码/解析 uint,自动识别变量长度
|
||||
fmt.Println(gbinary.DecodeToUint(gbinary.EncodeUint(1)))
|
||||
fmt.Println(gbinary.DecodeToUint(gbinary.EncodeUint(300)))
|
||||
fmt.Println(gbinary.DecodeToUint(gbinary.EncodeUint(70000)))
|
||||
fmt.Println(gbinary.DecodeToUint(gbinary.EncodeUint(2000000000)))
|
||||
fmt.Println(gbinary.DecodeToUint(gbinary.EncodeUint(500000000000)))
|
||||
|
||||
// 编码/解析 int8/16/32/64
|
||||
fmt.Println(gbinary.DecodeToInt8(gbinary.EncodeInt8(int8(100))))
|
||||
fmt.Println(gbinary.DecodeToInt16(gbinary.EncodeInt16(int16(100))))
|
||||
fmt.Println(gbinary.DecodeToInt32(gbinary.EncodeInt32(int32(100))))
|
||||
fmt.Println(gbinary.DecodeToInt64(gbinary.EncodeInt64(int64(100))))
|
||||
|
||||
// 编码/解析 uint8/16/32/64
|
||||
fmt.Println(gbinary.DecodeToUint8(gbinary.EncodeUint8(uint8(100))))
|
||||
fmt.Println(gbinary.DecodeToUint16(gbinary.EncodeUint16(uint16(100))))
|
||||
fmt.Println(gbinary.DecodeToUint32(gbinary.EncodeUint32(uint32(100))))
|
||||
fmt.Println(gbinary.DecodeToUint64(gbinary.EncodeUint64(uint64(100))))
|
||||
|
||||
// 编码/解析 string
|
||||
fmt.Println(gbinary.DecodeToString(gbinary.EncodeString("I'm string!")))
|
||||
}
|
||||
33
.example/encoding/gbinary/bits1.go
Normal file
33
.example/encoding/gbinary/bits1.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 传感器状态,0:已下线, 1:开启, 2:关闭, 3:待机
|
||||
count := 100
|
||||
status := 1
|
||||
|
||||
// 网关编码
|
||||
bits := make([]gbinary.Bit, 0)
|
||||
for i := 0; i < count; i++ {
|
||||
bits = gbinary.EncodeBits(bits, status, 2)
|
||||
}
|
||||
buffer := gbinary.EncodeBitsToBytes(bits)
|
||||
fmt.Println("buffer length:", len(buffer))
|
||||
|
||||
/* 上报过程忽略,这里只展示编码/解码示例 */
|
||||
|
||||
// 平台解码
|
||||
alivecount := 0
|
||||
sensorbits := gbinary.DecodeBytesToBits(buffer)
|
||||
for i := 0; i < len(sensorbits); i += 2 {
|
||||
if gbinary.DecodeBits(sensorbits[i:i+2]) == 1 {
|
||||
alivecount++
|
||||
}
|
||||
}
|
||||
fmt.Println("alived sensor:", alivecount)
|
||||
}
|
||||
33
.example/encoding/gbinary/bits2.go
Normal file
33
.example/encoding/gbinary/bits2.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Meta元数据文件数据结构:[键名哈希64(64bit,8byte) 键名长度(8bit,1byte) 键值长度(24bit,3byte) 数据文件偏移量(40bit,5byte)](变长)
|
||||
hash := 521369841259754125
|
||||
klen := 12
|
||||
vlen := 35535
|
||||
offset := 80000000
|
||||
|
||||
// 编码
|
||||
bits := make([]gbinary.Bit, 0)
|
||||
bits = gbinary.EncodeBits(bits, hash, 64)
|
||||
bits = gbinary.EncodeBits(bits, klen, 8)
|
||||
bits = gbinary.EncodeBits(bits, vlen, 24)
|
||||
bits = gbinary.EncodeBits(bits, offset, 40)
|
||||
buffer := gbinary.EncodeBitsToBytes(bits)
|
||||
fmt.Println("meta length:", len(buffer))
|
||||
|
||||
/* 文件存储及数据查询过程忽略,这里只展示元数据编码/解码示例 */
|
||||
|
||||
// 解码
|
||||
metabits := gbinary.DecodeBytesToBits(buffer)
|
||||
fmt.Println("hash :", gbinary.DecodeBits(metabits[0:64]))
|
||||
fmt.Println("klen :", gbinary.DecodeBits(metabits[64:72]))
|
||||
fmt.Println("vlen :", gbinary.DecodeBits(metabits[72:96]))
|
||||
fmt.Println("offset:", gbinary.DecodeBits(metabits[96:136]))
|
||||
}
|
||||
20
.example/encoding/gcfg/gcfg1.go
Normal file
20
.example/encoding/gcfg/gcfg1.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(g.Config().Get("redis"))
|
||||
|
||||
type RedisConfig struct {
|
||||
Disk string
|
||||
Cache string
|
||||
}
|
||||
|
||||
redisCfg := new(RedisConfig)
|
||||
fmt.Println(g.Config().GetStruct("redis", redisCfg))
|
||||
fmt.Println(redisCfg)
|
||||
}
|
||||
20
.example/encoding/gcharset/gcharset.go
Normal file
20
.example/encoding/gcharset/gcharset.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gcharset"
|
||||
)
|
||||
|
||||
func main() {
|
||||
src := "~{;(<dR;:x>F#,6@WCN^O`GW!#"
|
||||
srcCharset := "GB2312"
|
||||
dstCharset := "UTF-8"
|
||||
str, err := gcharset.Convert(dstCharset, srcCharset, src)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(str)
|
||||
// output:
|
||||
// 花间一壶酒,独酌无相亲。
|
||||
}
|
||||
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)
|
||||
}
|
||||
20
.example/encoding/ghash/ghash_repeat_check.go
Normal file
20
.example/encoding/ghash/ghash_repeat_check.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/gogf/gf/encoding/ghash"
|
||||
)
|
||||
|
||||
func main() {
|
||||
m := make(map[uint64]bool)
|
||||
for i := 0; i < 100000000; i++ {
|
||||
hash := ghash.BKDRHash64([]byte("key_" + strconv.Itoa(i)))
|
||||
if _, ok := m[hash]; ok {
|
||||
fmt.Printf("duplicated hash %d\n", hash)
|
||||
} else {
|
||||
m[hash] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
155
.example/encoding/gjson/gjson.go
Normal file
155
.example/encoding/gjson/gjson.go
Normal file
@ -0,0 +1,155 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
)
|
||||
|
||||
func getByPattern() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100,
|
||||
"list" : [
|
||||
{"name" : "小明", "score" : 60},
|
||||
{"name" : "John", "score" : 99.5}
|
||||
]
|
||||
}
|
||||
}`
|
||||
j, err := gjson.DecodeToJson([]byte(data))
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
fmt.Println("John Score:", j.GetFloat32("users.list.1.score"))
|
||||
}
|
||||
}
|
||||
|
||||
// 当键名存在"."号时,检索优先级:键名->层级,因此不会引起歧义
|
||||
func testMultiDots() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100
|
||||
},
|
||||
"users.count" : 101
|
||||
}`
|
||||
j, err := gjson.DecodeToJson([]byte(data))
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
fmt.Println("Users Count:", j.GetInt("users.count"))
|
||||
}
|
||||
}
|
||||
|
||||
// 设置数据
|
||||
func testSet() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100
|
||||
}
|
||||
}`
|
||||
j, err := gjson.DecodeToJson([]byte(data))
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
j.Set("users.count", 1)
|
||||
j.Set("users.list", []string{"John", "小明"})
|
||||
c, _ := j.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
}
|
||||
|
||||
// 将Json数据转换为其他数据格式
|
||||
func testConvert() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100,
|
||||
"list" : ["John", "小明"]
|
||||
}
|
||||
}`
|
||||
j, err := gjson.DecodeToJson([]byte(data))
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
c, _ := j.ToJson()
|
||||
fmt.Println("JSON:")
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("XML:")
|
||||
c, _ = j.ToXmlIndent()
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("YAML:")
|
||||
c, _ = j.ToYaml()
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("TOML:")
|
||||
c, _ = j.ToToml()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
}
|
||||
|
||||
func testSplitChar() {
|
||||
var v interface{}
|
||||
j := gjson.New(nil)
|
||||
t1 := gtime.TimestampNano()
|
||||
j.Set("a.b.c.d.e.f.g.h.i.j.k", 1)
|
||||
t2 := gtime.TimestampNano()
|
||||
fmt.Println(t2 - t1)
|
||||
|
||||
t5 := gtime.TimestampNano()
|
||||
v = j.Get("a.b.c.d.e.f.g.h.i.j.k")
|
||||
t6 := gtime.TimestampNano()
|
||||
fmt.Println(v)
|
||||
fmt.Println(t6 - t5)
|
||||
|
||||
j.SetSplitChar('#')
|
||||
|
||||
t7 := gtime.TimestampNano()
|
||||
v = j.Get("a#b#c#d#e#f#g#h#i#j#k")
|
||||
t8 := gtime.TimestampNano()
|
||||
fmt.Println(v)
|
||||
fmt.Println(t8 - t7)
|
||||
}
|
||||
|
||||
func testViolenceCheck() {
|
||||
j := gjson.New(nil)
|
||||
t1 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t2 := gtime.TimestampNano()
|
||||
fmt.Println(t2 - t1)
|
||||
|
||||
t3 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t4 := gtime.TimestampNano()
|
||||
fmt.Println(t4 - t3)
|
||||
|
||||
t5 := gtime.TimestampNano()
|
||||
j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a")
|
||||
t6 := gtime.TimestampNano()
|
||||
fmt.Println(t6 - t5)
|
||||
|
||||
j.SetViolenceCheck(false)
|
||||
|
||||
t7 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t8 := gtime.TimestampNano()
|
||||
fmt.Println(t8 - t7)
|
||||
|
||||
t9 := gtime.TimestampNano()
|
||||
j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a")
|
||||
t10 := gtime.TimestampNano()
|
||||
fmt.Println(t10 - t9)
|
||||
}
|
||||
|
||||
func main() {
|
||||
testViolenceCheck()
|
||||
}
|
||||
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)
|
||||
|
||||
}
|
||||
19
.example/encoding/gjson/issue360.go
Normal file
19
.example/encoding/gjson/issue360.go
Normal 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)
|
||||
}
|
||||
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: ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
217
.example/encoding/gparser/gparser.go
Normal file
217
.example/encoding/gparser/gparser.go
Normal file
@ -0,0 +1,217 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
)
|
||||
|
||||
func getWithPattern1() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100,
|
||||
"list" : [
|
||||
{"name" : "Ming", "score" : 60},
|
||||
{"name" : "John", "score" : 99.5}
|
||||
]
|
||||
}
|
||||
}`
|
||||
|
||||
if p, e := gparser.LoadContent([]byte(data)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
fmt.Println("John Score:", p.GetFloat32("users.list.1.score"))
|
||||
}
|
||||
}
|
||||
|
||||
func getWithPattern2() {
|
||||
data :=
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<note>
|
||||
<to>Tove</to>
|
||||
<from>Jani</from>
|
||||
<heading>Reminder</heading>
|
||||
<body>Don't forget me this weekend!</body>
|
||||
</note>`
|
||||
|
||||
if p, e := gparser.LoadContent([]byte(data)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
fmt.Println("Heading:", p.GetString("note.heading"))
|
||||
}
|
||||
}
|
||||
|
||||
// 当键名存在"."号时,检索优先级:键名->层级,因此不会引起歧义
|
||||
func multiDots1() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100
|
||||
},
|
||||
"users.count" : 101
|
||||
}`
|
||||
if p, e := gparser.LoadContent([]byte(data)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
fmt.Println("Users Count:", p.Get("users.count"))
|
||||
}
|
||||
}
|
||||
|
||||
func multiDots2() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : {
|
||||
"type1" : 1,
|
||||
"type2" : 2
|
||||
},
|
||||
"count.type1" : 100
|
||||
}
|
||||
}`
|
||||
if p, e := gparser.LoadContent([]byte(data)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
fmt.Println("Users Count:", p.Get("users.count.type1"))
|
||||
fmt.Println("Users Count:", p.Get("users.count.type2"))
|
||||
}
|
||||
}
|
||||
|
||||
// 设置数据
|
||||
func set1() {
|
||||
data :=
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<article>
|
||||
<count>10</count>
|
||||
<list><title>gf article1</title><content>gf content1</content></list>
|
||||
<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)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
p.Set("article.list.0", nil)
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
// {"article":{"count":"10","list":[{"content":"gf content2","title":"gf article2"},{"content":"gf content3","title":"gf article3"}]}}
|
||||
}
|
||||
}
|
||||
|
||||
func set2() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
"count" : 100
|
||||
}
|
||||
}`
|
||||
if p, e := gparser.LoadContent([]byte(data)); e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
p.Set("users.count", 1)
|
||||
p.Set("users.list", []string{"John", "小明"})
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
}
|
||||
|
||||
func makeXml1() {
|
||||
p := gparser.New(nil)
|
||||
p.Set("name", "john")
|
||||
p.Set("age", 18)
|
||||
p.Set("scores", map[string]int{
|
||||
"语文": 100,
|
||||
"数学": 100,
|
||||
"英语": 100,
|
||||
})
|
||||
c, _ := p.ToXmlIndent("simple-xml")
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
|
||||
func makeJson1() {
|
||||
type Order struct {
|
||||
Id int `json:"id"`
|
||||
Price float32 `json:"price"`
|
||||
}
|
||||
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})
|
||||
fmt.Println("Order 1 Price:", p.Get("orders.list.1.price"))
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
|
||||
func makeJson2() {
|
||||
p := gparser.New(map[string]string{
|
||||
"k1": "v1",
|
||||
"k2": "v2",
|
||||
})
|
||||
p.Set("k1.1", []int{1, 2, 3})
|
||||
//p.Set("0.0.1", []int{1,2,3})
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
|
||||
func makeJson3() {
|
||||
p := gparser.New([]string{"a"})
|
||||
p.Set("0.0.0", []int{1, 2, 3})
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
|
||||
func toStruct1() {
|
||||
type Info struct {
|
||||
Name string
|
||||
Url string
|
||||
}
|
||||
o := Info{}
|
||||
p := gparser.New(map[string]string{
|
||||
"Name": "gf",
|
||||
"Url": "https://gitee.com/johng",
|
||||
})
|
||||
p.ToStruct(&o)
|
||||
fmt.Println("Name:", o.Name)
|
||||
fmt.Println("Url :", o.Url)
|
||||
}
|
||||
|
||||
func convert() {
|
||||
p := gparser.New(map[string]string{
|
||||
"name": "gf",
|
||||
"site": "https://gitee.com/johng",
|
||||
})
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println("JSON:")
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("XML:")
|
||||
c, _ = p.ToXmlIndent()
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("YAML:")
|
||||
c, _ = p.ToYaml()
|
||||
fmt.Println(string(c))
|
||||
fmt.Println("======================")
|
||||
|
||||
fmt.Println("TOML:")
|
||||
c, _ = p.ToToml()
|
||||
fmt.Println(string(c))
|
||||
|
||||
}
|
||||
|
||||
func remove1() {
|
||||
p := gparser.New(map[string]string{
|
||||
"k1": "v1",
|
||||
"k2": "v2",
|
||||
})
|
||||
p.Set("0.0.0.0.0.0.0.0", []int{1, 2, 3})
|
||||
p.Remove("0.0")
|
||||
c, _ := p.ToJson()
|
||||
fmt.Println(string(c))
|
||||
}
|
||||
|
||||
func main() {
|
||||
toStruct1()
|
||||
}
|
||||
21
.example/encoding/gparser/gparser_xml.go
Normal file
21
.example/encoding/gparser/gparser_xml.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import "github.com/gogf/gf/encoding/gparser"
|
||||
|
||||
func main() {
|
||||
xml := `<?xml version="1.0" encoding="GBK"?>
|
||||
|
||||
<Output type="o">
|
||||
<itotalSize>0</itotalSize>
|
||||
<ipageSize>1</ipageSize>
|
||||
<ipageIndex>2</ipageIndex>
|
||||
<itotalRecords>3</itotalRecords>
|
||||
<nworkOrderDtos/>
|
||||
<nworkOrderFrontXML/>
|
||||
</Output>`
|
||||
p, err := gparser.LoadContent([]byte(xml))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
p.Dump()
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user