From 5878be1e035dca0d3b6f35badc8e42b1ad59cf7e Mon Sep 17 00:00:00 2001 From: John Date: Mon, 27 Nov 2017 12:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=8C=E5=86=85=E9=83=A8=E5=8C=85=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 7 ++ g/{core/types => container}/gbtree/gbtree.go | 0 .../types => container}/gbtree/gbtree_test.go | 0 g/{core/types => container}/glist/safelist.go | 0 .../types => container}/gmap/int_bool_map.go | 0 .../types => container}/gmap/int_int_map.go | 0 .../gmap/int_interface_map.go | 0 .../gmap/int_string_map.go | 0 .../gmap/interface_interface_map.go | 0 .../gmap/string_bool_map.go | 0 .../gmap/string_int_map.go | 0 .../gmap/string_interface_map.go | 0 .../gmap/string_string_map.go | 0 .../gmap/uint_interface_map.go | 0 g/{core/types => container}/gset/int64_set.go | 0 g/{core/types => container}/gset/int_set.go | 0 .../types => container}/gset/interface_set.go | 0 .../types => container}/gset/string_set.go | 0 g/core/gmvc/controller.go | 5 -- g/core/gmvc/model.go | 3 - g/core/gmvc/view.go | 3 - g/core/types/gbtree/btree_mem.go | 76 ------------------- g/database/gdb/db.go | 12 +-- g/database/gdb/db_base.go | 2 +- g/database/gdb/db_mysql.go | 2 +- g/database/gdb/db_pgsql.go | 2 +- g/encoding/gjson/json.go | 2 +- g/encoding/gmd5/gmd5.go | 2 +- g/encoding/gsha1/gsha1.go | 4 +- g/net/ghttp/http_request.go | 2 +- g/net/ghttp/http_response.go | 4 +- g/net/ghttp/http_server.go | 2 +- g/net/ghttp/http_server_handle.go | 10 +-- g/net/gscanner/scanner.go | 2 +- g/net/gtcp/tcp.go | 2 +- g/net/gtcp/tcp_server.go | 2 +- g/net/gudp/udp.go | 2 +- g/net/gudp/udp_server.go | 2 +- g/os/gcache/gcache.go | 4 +- g/os/gfilepool/gfilepool.go | 6 +- g/os/gfilespace/gfilespace.go | 2 +- g/os/gfilespace/gfilespace_api.go | 5 +- g/os/glog/glog.go | 2 +- g/os/gmmap/gmmap_test.go | 3 +- {gexample => geg}/db/mysql/mysql.go | 0 {gexample => geg}/db/pgsql/pgsql.go | 0 {gexample => geg}/encoding/ghash.go | 0 {gexample => geg}/encoding/json.go | 0 {gexample => geg}/encoding/json_test.go | 0 {gexample => geg}/net/gluster_client.go | 0 {gexample => geg}/net/http_client.go | 0 {gexample => geg}/net/http_server.go | 0 {gexample => geg}/net/raft.go | 0 {gexample => geg}/net/raft_client.go | 0 {gexample => geg}/net/scanner.go | 0 {gexample => geg}/net/tcp_server.go | 0 {gexample => geg}/net/udp.go | 0 {gexample => geg}/net/udp_server.go | 0 {gexample => geg}/os/console.go | 0 {gexample => geg}/os/file.go | 3 +- {gexample => geg}/os/gcache_test.go | 0 {gexample => geg}/os/gfilespace.go | 0 {gexample => geg}/other/reflect.go | 0 {gexample => geg}/other/test.go | 74 +++++++++--------- {gexample => geg}/other/test_test.go | 0 {gexample => geg}/types/gbtree.go | 0 66 files changed, 85 insertions(+), 162 deletions(-) rename g/{core/types => container}/gbtree/gbtree.go (100%) rename g/{core/types => container}/gbtree/gbtree_test.go (100%) rename g/{core/types => container}/glist/safelist.go (100%) rename g/{core/types => container}/gmap/int_bool_map.go (100%) rename g/{core/types => container}/gmap/int_int_map.go (100%) rename g/{core/types => container}/gmap/int_interface_map.go (100%) rename g/{core/types => container}/gmap/int_string_map.go (100%) rename g/{core/types => container}/gmap/interface_interface_map.go (100%) rename g/{core/types => container}/gmap/string_bool_map.go (100%) rename g/{core/types => container}/gmap/string_int_map.go (100%) rename g/{core/types => container}/gmap/string_interface_map.go (100%) rename g/{core/types => container}/gmap/string_string_map.go (100%) rename g/{core/types => container}/gmap/uint_interface_map.go (100%) rename g/{core/types => container}/gset/int64_set.go (100%) rename g/{core/types => container}/gset/int_set.go (100%) rename g/{core/types => container}/gset/interface_set.go (100%) rename g/{core/types => container}/gset/string_set.go (100%) delete mode 100644 g/core/gmvc/controller.go delete mode 100644 g/core/gmvc/model.go delete mode 100644 g/core/gmvc/view.go delete mode 100644 g/core/types/gbtree/btree_mem.go rename {gexample => geg}/db/mysql/mysql.go (100%) rename {gexample => geg}/db/pgsql/pgsql.go (100%) rename {gexample => geg}/encoding/ghash.go (100%) rename {gexample => geg}/encoding/json.go (100%) rename {gexample => geg}/encoding/json_test.go (100%) rename {gexample => geg}/net/gluster_client.go (100%) rename {gexample => geg}/net/http_client.go (100%) rename {gexample => geg}/net/http_server.go (100%) rename {gexample => geg}/net/raft.go (100%) rename {gexample => geg}/net/raft_client.go (100%) rename {gexample => geg}/net/scanner.go (100%) rename {gexample => geg}/net/tcp_server.go (100%) rename {gexample => geg}/net/udp.go (100%) rename {gexample => geg}/net/udp_server.go (100%) rename {gexample => geg}/os/console.go (100%) rename {gexample => geg}/os/file.go (96%) rename {gexample => geg}/os/gcache_test.go (100%) rename {gexample => geg}/os/gfilespace.go (100%) rename {gexample => geg}/other/reflect.go (100%) rename {gexample => geg}/other/test.go (86%) rename {gexample => geg}/other/test_test.go (100%) rename {gexample => geg}/types/gbtree.go (100%) diff --git a/README.MD b/README.MD index b8926cbd6..3171b824a 100644 --- a/README.MD +++ b/README.MD @@ -9,3 +9,10 @@ go get -u gitee.com/johng/gf ```go import "gitee.com/johng/gf/g/xxx" ``` + +# 说明 + . + ├── g 框架目录 + ├── geg 框架示例 + ├── vendor 第三方包 + └── version.go 版本信息 \ No newline at end of file diff --git a/g/core/types/gbtree/gbtree.go b/g/container/gbtree/gbtree.go similarity index 100% rename from g/core/types/gbtree/gbtree.go rename to g/container/gbtree/gbtree.go diff --git a/g/core/types/gbtree/gbtree_test.go b/g/container/gbtree/gbtree_test.go similarity index 100% rename from g/core/types/gbtree/gbtree_test.go rename to g/container/gbtree/gbtree_test.go diff --git a/g/core/types/glist/safelist.go b/g/container/glist/safelist.go similarity index 100% rename from g/core/types/glist/safelist.go rename to g/container/glist/safelist.go diff --git a/g/core/types/gmap/int_bool_map.go b/g/container/gmap/int_bool_map.go similarity index 100% rename from g/core/types/gmap/int_bool_map.go rename to g/container/gmap/int_bool_map.go diff --git a/g/core/types/gmap/int_int_map.go b/g/container/gmap/int_int_map.go similarity index 100% rename from g/core/types/gmap/int_int_map.go rename to g/container/gmap/int_int_map.go diff --git a/g/core/types/gmap/int_interface_map.go b/g/container/gmap/int_interface_map.go similarity index 100% rename from g/core/types/gmap/int_interface_map.go rename to g/container/gmap/int_interface_map.go diff --git a/g/core/types/gmap/int_string_map.go b/g/container/gmap/int_string_map.go similarity index 100% rename from g/core/types/gmap/int_string_map.go rename to g/container/gmap/int_string_map.go diff --git a/g/core/types/gmap/interface_interface_map.go b/g/container/gmap/interface_interface_map.go similarity index 100% rename from g/core/types/gmap/interface_interface_map.go rename to g/container/gmap/interface_interface_map.go diff --git a/g/core/types/gmap/string_bool_map.go b/g/container/gmap/string_bool_map.go similarity index 100% rename from g/core/types/gmap/string_bool_map.go rename to g/container/gmap/string_bool_map.go diff --git a/g/core/types/gmap/string_int_map.go b/g/container/gmap/string_int_map.go similarity index 100% rename from g/core/types/gmap/string_int_map.go rename to g/container/gmap/string_int_map.go diff --git a/g/core/types/gmap/string_interface_map.go b/g/container/gmap/string_interface_map.go similarity index 100% rename from g/core/types/gmap/string_interface_map.go rename to g/container/gmap/string_interface_map.go diff --git a/g/core/types/gmap/string_string_map.go b/g/container/gmap/string_string_map.go similarity index 100% rename from g/core/types/gmap/string_string_map.go rename to g/container/gmap/string_string_map.go diff --git a/g/core/types/gmap/uint_interface_map.go b/g/container/gmap/uint_interface_map.go similarity index 100% rename from g/core/types/gmap/uint_interface_map.go rename to g/container/gmap/uint_interface_map.go diff --git a/g/core/types/gset/int64_set.go b/g/container/gset/int64_set.go similarity index 100% rename from g/core/types/gset/int64_set.go rename to g/container/gset/int64_set.go diff --git a/g/core/types/gset/int_set.go b/g/container/gset/int_set.go similarity index 100% rename from g/core/types/gset/int_set.go rename to g/container/gset/int_set.go diff --git a/g/core/types/gset/interface_set.go b/g/container/gset/interface_set.go similarity index 100% rename from g/core/types/gset/interface_set.go rename to g/container/gset/interface_set.go diff --git a/g/core/types/gset/string_set.go b/g/container/gset/string_set.go similarity index 100% rename from g/core/types/gset/string_set.go rename to g/container/gset/string_set.go diff --git a/g/core/gmvc/controller.go b/g/core/gmvc/controller.go deleted file mode 100644 index c5f6faf85..000000000 --- a/g/core/gmvc/controller.go +++ /dev/null @@ -1,5 +0,0 @@ -package gmvc - - - - diff --git a/g/core/gmvc/model.go b/g/core/gmvc/model.go deleted file mode 100644 index f591af65e..000000000 --- a/g/core/gmvc/model.go +++ /dev/null @@ -1,3 +0,0 @@ -package gmvc - - diff --git a/g/core/gmvc/view.go b/g/core/gmvc/view.go deleted file mode 100644 index f591af65e..000000000 --- a/g/core/gmvc/view.go +++ /dev/null @@ -1,3 +0,0 @@ -package gmvc - - diff --git a/g/core/types/gbtree/btree_mem.go b/g/core/types/gbtree/btree_mem.go deleted file mode 100644 index 70bf79bf6..000000000 --- a/g/core/types/gbtree/btree_mem.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2014 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build ignore - -// This binary compares memory usage between btree and gollrb. -package gbtree - -import ( - "flag" - "fmt" - "math/rand" - "runtime" - "time" - - "github.com/google/btree" - "github.com/petar/GoLLRB/llrb" -) - -var ( - size = flag.Int("size", 1000000, "size of the tree to build") - degree = flag.Int("degree", 8, "degree of btree") - gollrb = flag.Bool("llrb", false, "use llrb instead of btree") -) - -func main() { - flag.Parse() - vals := rand.Perm(*size) - var t, v interface{} - v = vals - var stats runtime.MemStats - for i := 0; i < 10; i++ { - runtime.GC() - } - fmt.Println("-------- BEFORE ----------") - runtime.ReadMemStats(&stats) - fmt.Printf("%+v\n", stats) - start := time.Now() - if *gollrb { - tr := llrb.New() - for _, v := range vals { - tr.ReplaceOrInsert(llrb.Int(v)) - } - t = tr // keep it around - } else { - tr := btree.New(*degree) - for _, v := range vals { - tr.ReplaceOrInsert(btree.Int(v)) - } - t = tr // keep it around - } - fmt.Printf("%v inserts in %v\n", *size, time.Since(start)) - fmt.Println("-------- AFTER ----------") - runtime.ReadMemStats(&stats) - fmt.Printf("%+v\n", stats) - for i := 0; i < 10; i++ { - runtime.GC() - } - fmt.Println("-------- AFTER GC ----------") - runtime.ReadMemStats(&stats) - fmt.Printf("%+v\n", stats) - if t == v { - fmt.Println("to make sure vals and tree aren't GC'd") - } -} \ No newline at end of file diff --git a/g/database/gdb/db.go b/g/database/gdb/db.go index 6ef6e59be..8f0e76408 100644 --- a/g/database/gdb/db.go +++ b/g/database/gdb/db.go @@ -2,15 +2,15 @@ package gdb import ( - "database/sql" - "errors" "fmt" - "gf/g/util/grand" "sync" - "gf/g/os/glog" - _ "github.com/go-sql-driver/mysql" + "errors" + "database/sql" + "../../os/glog" + "../../os/gcache" + "../../util/grand" _ "github.com/lib/pq" - "gf/g/os/gcache" + _ "github.com/go-sql-driver/mysql" ) const ( diff --git a/g/database/gdb/db_base.go b/g/database/gdb/db_base.go index e828aee40..6de706b31 100644 --- a/g/database/gdb/db_base.go +++ b/g/database/gdb/db_base.go @@ -5,7 +5,7 @@ import ( "errors" "strings" "database/sql" - "gf/g/os/glog" + "../../os/glog" ) // 关闭链接 diff --git a/g/database/gdb/db_mysql.go b/g/database/gdb/db_mysql.go index f23ec698b..f39a8c256 100644 --- a/g/database/gdb/db_mysql.go +++ b/g/database/gdb/db_mysql.go @@ -3,7 +3,7 @@ package gdb import ( "database/sql" "fmt" - "gf/g/os/glog" + "../../os/glog" ) // 数据库链接对象 diff --git a/g/database/gdb/db_pgsql.go b/g/database/gdb/db_pgsql.go index 499b36796..4737cc8fa 100644 --- a/g/database/gdb/db_pgsql.go +++ b/g/database/gdb/db_pgsql.go @@ -4,7 +4,7 @@ import ( "database/sql" "fmt" "regexp" - "gf/g/os/glog" + "../../os/glog" ) // postgresql的适配 diff --git a/g/encoding/gjson/json.go b/g/encoding/gjson/json.go index f5fbae6ed..f871f0027 100644 --- a/g/encoding/gjson/json.go +++ b/g/encoding/gjson/json.go @@ -5,7 +5,7 @@ import ( "errors" "strings" "strconv" - "gf/g/os/glog" + "../../os/glog" "fmt" ) diff --git a/g/encoding/gmd5/gmd5.go b/g/encoding/gmd5/gmd5.go index 5d6ccbce3..7d11e92b5 100644 --- a/g/encoding/gmd5/gmd5.go +++ b/g/encoding/gmd5/gmd5.go @@ -7,7 +7,7 @@ import ( "reflect" "os" "io" - "gf/g/os/glog" + "../../os/glog" ) // 将任意类型的变量进行md5摘要(注意map等非排序变量造成的不同结果) diff --git a/g/encoding/gsha1/gsha1.go b/g/encoding/gsha1/gsha1.go index de293ae1f..0a59676d5 100644 --- a/g/encoding/gsha1/gsha1.go +++ b/g/encoding/gsha1/gsha1.go @@ -5,8 +5,8 @@ import ( "encoding/hex" "os" "io" - "gf/g/os/glog" - "gf/g/encoding/gmd5" + "../../os/glog" + "../../encoding/gmd5" ) // 将任意类型的变量进行SHA摘要(注意map等非排序变量造成的不同结果) diff --git a/g/net/ghttp/http_request.go b/g/net/ghttp/http_request.go index 266ade964..4f55b1d2a 100644 --- a/g/net/ghttp/http_request.go +++ b/g/net/ghttp/http_request.go @@ -2,7 +2,7 @@ package ghttp import ( "io/ioutil" - "gf/g/encoding/gjson" + "../../encoding/gjson" ) // 获得get参数 diff --git a/g/net/ghttp/http_response.go b/g/net/ghttp/http_response.go index 2a06b8710..1dd2f4a94 100644 --- a/g/net/ghttp/http_response.go +++ b/g/net/ghttp/http_response.go @@ -1,9 +1,9 @@ package ghttp import ( - "gf/g/encoding/gjson" + "../../encoding/gjson" "io/ioutil" - "gf/g/os/glog" + "../../os/glog" ) type ResponseJson struct { diff --git a/g/net/ghttp/http_server.go b/g/net/ghttp/http_server.go index 3e5113962..62f26bada 100644 --- a/g/net/ghttp/http_server.go +++ b/g/net/ghttp/http_server.go @@ -8,7 +8,7 @@ import ( "time" "log" "regexp" - "gf/g/os/glog" + "../../os/glog" ) // 执行 diff --git a/g/net/ghttp/http_server_handle.go b/g/net/ghttp/http_server_handle.go index 33485e453..830f391c0 100644 --- a/g/net/ghttp/http_server_handle.go +++ b/g/net/ghttp/http_server_handle.go @@ -1,15 +1,15 @@ package ghttp import ( - "net/http" - "strings" - "path/filepath" - "gf/g/os/gfile" "os" "fmt" "sort" + "strings" "net/url" - "gf/g/encoding/ghtml" + "net/http" + "path/filepath" + "../../os/gfile" + "../../encoding/ghtml" ) // 默认HTTP Server处理入口,底层默认使用了gorutine调用该接口 diff --git a/g/net/gscanner/scanner.go b/g/net/gscanner/scanner.go index 8cbd1114f..dc09e2733 100644 --- a/g/net/gscanner/scanner.go +++ b/g/net/gscanner/scanner.go @@ -3,11 +3,11 @@ package gscanner import ( "net" - "gf/g/net/gip" "fmt" "errors" "sync" "time" + "../../net/gip" ) type scanner struct { diff --git a/g/net/gtcp/tcp.go b/g/net/gtcp/tcp.go index 7ca55b88e..89e6ea731 100644 --- a/g/net/gtcp/tcp.go +++ b/g/net/gtcp/tcp.go @@ -2,7 +2,7 @@ package gtcp import ( "net" - "gf/g/os/glog" + "../../os/glog" ) // tcp server结构体 diff --git a/g/net/gtcp/tcp_server.go b/g/net/gtcp/tcp_server.go index 4f2dfd209..5f758406e 100644 --- a/g/net/gtcp/tcp_server.go +++ b/g/net/gtcp/tcp_server.go @@ -1,7 +1,7 @@ package gtcp import ( - "gf/g/os/glog" + "../../os/glog" ) // 执行监听 diff --git a/g/net/gudp/udp.go b/g/net/gudp/udp.go index e2a7000f2..8b349a5cb 100644 --- a/g/net/gudp/udp.go +++ b/g/net/gudp/udp.go @@ -2,7 +2,7 @@ package gudp import ( "net" - "log" + "../../os/glog" ) // tcp server结构体 diff --git a/g/net/gudp/udp_server.go b/g/net/gudp/udp_server.go index 58aeb9c9a..ecd7b5fcc 100644 --- a/g/net/gudp/udp_server.go +++ b/g/net/gudp/udp_server.go @@ -1,6 +1,6 @@ package gudp -import "log" +import "../../os/glog" // 执行监听 func (s *gUdpServer) Run() { diff --git a/g/os/gcache/gcache.go b/g/os/gcache/gcache.go index 1637e2cb6..47bb9d597 100644 --- a/g/os/gcache/gcache.go +++ b/g/os/gcache/gcache.go @@ -2,9 +2,9 @@ package gcache import ( "sync" - "gf/g/util/gtime" "time" - "gf/g/encoding/ghash" + "../../util/gtime" + "../../encoding/ghash" ) const ( diff --git a/g/os/gfilepool/gfilepool.go b/g/os/gfilepool/gfilepool.go index 8f5e58e66..e48632b1a 100644 --- a/g/os/gfilepool/gfilepool.go +++ b/g/os/gfilepool/gfilepool.go @@ -2,11 +2,11 @@ package gfilepool import ( "os" - "gf/g/core/types/glist" - "gf/g/util/gtime" "time" - "gf/g/core/types/gmap" "strconv" + "../../util/gtime" + "../../container/gmap" + "../../container/glist" ) // 文件指针池 diff --git a/g/os/gfilespace/gfilespace.go b/g/os/gfilespace/gfilespace.go index 79771d086..e4c9fa957 100644 --- a/g/os/gfilespace/gfilespace.go +++ b/g/os/gfilespace/gfilespace.go @@ -4,7 +4,7 @@ package gfilespace import ( "sync" - "gf/g/core/types/gbtree" + "../../container/gbtree" ) // 文件空间管理结构体 diff --git a/g/os/gfilespace/gfilespace_api.go b/g/os/gfilespace/gfilespace_api.go index 414cd87b6..7cbc5491c 100644 --- a/g/os/gfilespace/gfilespace_api.go +++ b/g/os/gfilespace/gfilespace_api.go @@ -1,8 +1,9 @@ package gfilespace import ( - "gf/g/core/types/gbtree" - "gf/g/encoding/gbinary" + + "../../encoding/gbinary" + "../../container/gbtree" ) // 添加空闲空间到管理器 diff --git a/g/os/glog/glog.go b/g/os/glog/glog.go index 151f2e4c3..aad2b8b01 100644 --- a/g/os/glog/glog.go +++ b/g/os/glog/glog.go @@ -9,7 +9,7 @@ import ( "path/filepath" "time" "fmt" - "gf/g/os/gfile" + "../../os/gfile" ) type Logger struct { diff --git a/g/os/gmmap/gmmap_test.go b/g/os/gmmap/gmmap_test.go index 2d93e7ffd..7c768d1ee 100644 --- a/g/os/gmmap/gmmap_test.go +++ b/g/os/gmmap/gmmap_test.go @@ -4,11 +4,10 @@ import ( "bytes" "io/ioutil" "testing" - "gf/g/os/gmmap" ) func TestMap(t *testing.T) { - data, err := gmmap.Map("mmap_test.go") + data, err := Map("mmap_test.go") if err != nil { t.Fatalf("Open: %v", err) } diff --git a/gexample/db/mysql/mysql.go b/geg/db/mysql/mysql.go similarity index 100% rename from gexample/db/mysql/mysql.go rename to geg/db/mysql/mysql.go diff --git a/gexample/db/pgsql/pgsql.go b/geg/db/pgsql/pgsql.go similarity index 100% rename from gexample/db/pgsql/pgsql.go rename to geg/db/pgsql/pgsql.go diff --git a/gexample/encoding/ghash.go b/geg/encoding/ghash.go similarity index 100% rename from gexample/encoding/ghash.go rename to geg/encoding/ghash.go diff --git a/gexample/encoding/json.go b/geg/encoding/json.go similarity index 100% rename from gexample/encoding/json.go rename to geg/encoding/json.go diff --git a/gexample/encoding/json_test.go b/geg/encoding/json_test.go similarity index 100% rename from gexample/encoding/json_test.go rename to geg/encoding/json_test.go diff --git a/gexample/net/gluster_client.go b/geg/net/gluster_client.go similarity index 100% rename from gexample/net/gluster_client.go rename to geg/net/gluster_client.go diff --git a/gexample/net/http_client.go b/geg/net/http_client.go similarity index 100% rename from gexample/net/http_client.go rename to geg/net/http_client.go diff --git a/gexample/net/http_server.go b/geg/net/http_server.go similarity index 100% rename from gexample/net/http_server.go rename to geg/net/http_server.go diff --git a/gexample/net/raft.go b/geg/net/raft.go similarity index 100% rename from gexample/net/raft.go rename to geg/net/raft.go diff --git a/gexample/net/raft_client.go b/geg/net/raft_client.go similarity index 100% rename from gexample/net/raft_client.go rename to geg/net/raft_client.go diff --git a/gexample/net/scanner.go b/geg/net/scanner.go similarity index 100% rename from gexample/net/scanner.go rename to geg/net/scanner.go diff --git a/gexample/net/tcp_server.go b/geg/net/tcp_server.go similarity index 100% rename from gexample/net/tcp_server.go rename to geg/net/tcp_server.go diff --git a/gexample/net/udp.go b/geg/net/udp.go similarity index 100% rename from gexample/net/udp.go rename to geg/net/udp.go diff --git a/gexample/net/udp_server.go b/geg/net/udp_server.go similarity index 100% rename from gexample/net/udp_server.go rename to geg/net/udp_server.go diff --git a/gexample/os/console.go b/geg/os/console.go similarity index 100% rename from gexample/os/console.go rename to geg/os/console.go diff --git a/gexample/os/file.go b/geg/os/file.go similarity index 96% rename from gexample/os/file.go rename to geg/os/file.go index f6baf27f6..bdbfabbce 100644 --- a/gexample/os/file.go +++ b/geg/os/file.go @@ -1,7 +1,8 @@ package main + import ( - "gf/g/os/gfile" + "../../../gf/g/os/gfile" "fmt" ) diff --git a/gexample/os/gcache_test.go b/geg/os/gcache_test.go similarity index 100% rename from gexample/os/gcache_test.go rename to geg/os/gcache_test.go diff --git a/gexample/os/gfilespace.go b/geg/os/gfilespace.go similarity index 100% rename from gexample/os/gfilespace.go rename to geg/os/gfilespace.go diff --git a/gexample/other/reflect.go b/geg/other/reflect.go similarity index 100% rename from gexample/other/reflect.go rename to geg/other/reflect.go diff --git a/gexample/other/test.go b/geg/other/test.go similarity index 86% rename from gexample/other/test.go rename to geg/other/test.go index 39d4d6855..c5a0ceb77 100644 --- a/gexample/other/test.go +++ b/geg/other/test.go @@ -3,6 +3,8 @@ package main import ( "fmt" "sync" + "github.com/boltdb/bolt" + "log" ) @@ -196,44 +198,44 @@ func main() { //fmt.Println(gtime.Microsecond() - t1) // //return - //db, err := bolt.Open("/tmp/my.db", 0600, nil) - //if err != nil { - // log.Fatal(err) - //} - //defer db.Close() - // - //tx, err := db.Begin(true) - //if err != nil { - // log.Fatal(err) - //} - //defer tx.Rollback() + db, err := bolt.Open("/tmp/my.db", 0600, nil) + if err != nil { + log.Fatal(err) + } + defer db.Close() - // Use the transaction... - //_, err = tx.CreateBucket([]byte("MyBucket")) - //if err != nil { - // log.Fatal(err) - //} + tx, err := db.Begin(true) + if err != nil { + log.Fatal(err) + } + defer tx.Rollback() - // Commit the transaction and check for error. - //if err := tx.Commit(); err != nil { - // log.Fatal(err) - //} - //t1 := gtime.Microsecond() - //db.Update(func(tx *bolt.Tx) error { - // b := tx.Bucket([]byte("MyBucket")) - // err := b.Put([]byte("answer"), []byte("11")) - // return err - //}) - //fmt.Println(gtime.Microsecond() - t1) - // - //t2 := gtime.Microsecond() - //db.View(func(tx *bolt.Tx) error { - // b := tx.Bucket([]byte("MyBucket")) - // v := b.Get([]byte("answer")) - // fmt.Printf("The answer is: %s\n", v) - // return nil - //}) - //fmt.Println(gtime.Microsecond() - t2) + //Use the transaction... + _, err = tx.CreateBucket([]byte("MyBucket")) + if err != nil { + log.Fatal(err) + } + + //Commit the transaction and check for error. + if err := tx.Commit(); err != nil { + log.Fatal(err) + } + t1 := gtime.Microsecond() + db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("MyBucket")) + err := b.Put([]byte("answer"), []byte("11")) + return err + }) + fmt.Println(gtime.Microsecond() - t1) + + t2 := gtime.Microsecond() + db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("MyBucket")) + v := b.Get([]byte("answer")) + fmt.Printf("The answer is: %s\n", v) + return nil + }) + fmt.Println(gtime.Microsecond() - t2) //return diff --git a/gexample/other/test_test.go b/geg/other/test_test.go similarity index 100% rename from gexample/other/test_test.go rename to geg/other/test_test.go diff --git a/gexample/types/gbtree.go b/geg/types/gbtree.go similarity index 100% rename from gexample/types/gbtree.go rename to geg/types/gbtree.go