From 05b76a14c002f254b354508b79e81fc1171dae18 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 3 Jan 2018 10:38:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8C=85=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=EF=BC=8C=E4=BE=BF=E4=BA=8Egodoc=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/container/gbtree/gbtree.go | 2 +- g/container/glist/safelist.go | 2 +- g/container/gmap/gmap.go | 8 ++++++++ g/container/gset/gset.go | 8 ++++++++ g/database/gdb/gdb.go | 3 +-- g/encoding/gbase64/gbase64.go | 2 +- g/encoding/gbinary/gbinary.go | 1 - g/encoding/gcompress/gcompress.go | 2 +- g/encoding/gcrc32/gcrc32.go | 2 +- g/encoding/ghash/ghash.go | 3 +-- g/encoding/ghtml/ghtml.go | 2 +- g/encoding/gjson/gjson.go | 2 +- g/encoding/gmd5/gmd5.go | 2 +- g/encoding/gsha1/gsha1.go | 2 +- g/encoding/gurl/url.go | 2 +- g/frame/gcfg/gcfg.go | 1 - g/frame/gins/gins.go | 3 +-- g/frame/gmvc/controller.go | 1 - g/frame/gmvc/model.go | 3 +-- g/frame/gmvc/view.go | 2 +- g/net/ghttp/ghttp.go | 8 ++++++++ g/net/ghttp/http_server.go | 1 - g/net/gipv4/gipv4.go | 1 + g/net/gipv6/gipv6.go | 2 +- g/net/grouter/grouter.go | 2 +- g/net/gscanner/scanner.go | 1 - g/net/gsmtp/smtp.go | 2 +- g/net/gtcp/tcp.go | 2 +- g/net/gudp/udp.go | 2 +- g/os/gcache/gcache.go | 2 +- g/os/gcmd/gcmd.go | 1 + g/os/genv/genv.go | 2 +- g/os/gfile/gfile.go | 2 +- g/os/gfilepool/gfilepool.go | 2 +- g/os/gfilespace/gfilespace.go | 2 -- g/os/gtime/time.go | 7 +++---- g/os/gview/gview.go | 6 +++--- g/util/grand/rand.go | 2 +- g/util/gregx/regx.go | 2 +- g/util/gutil/gutil.go | 2 +- g/util/gvalid/gvalid.go | 3 +-- 41 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 g/container/gmap/gmap.go create mode 100644 g/container/gset/gset.go create mode 100644 g/net/ghttp/ghttp.go diff --git a/g/container/gbtree/gbtree.go b/g/container/gbtree/gbtree.go index a5feaf38a..5bf90fc97 100644 --- a/g/container/gbtree/gbtree.go +++ b/g/container/gbtree/gbtree.go @@ -1,6 +1,6 @@ // from https://github.com/google/btree - +// B+ Tree package gbtree import ( diff --git a/g/container/glist/safelist.go b/g/container/glist/safelist.go index c66de59d7..20ba7a1d9 100644 --- a/g/container/glist/safelist.go +++ b/g/container/glist/safelist.go @@ -4,8 +4,8 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. // -// +// 并发安全的双向链表 package glist import ( diff --git a/g/container/gmap/gmap.go b/g/container/gmap/gmap.go new file mode 100644 index 000000000..2cc2c4952 --- /dev/null +++ b/g/container/gmap/gmap.go @@ -0,0 +1,8 @@ +// Copyright 2017 gf Author(https://gitee.com/johng/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://gitee.com/johng/gf. + +// 并发安全的MAP +package gmap diff --git a/g/container/gset/gset.go b/g/container/gset/gset.go new file mode 100644 index 000000000..af4d43d29 --- /dev/null +++ b/g/container/gset/gset.go @@ -0,0 +1,8 @@ +// Copyright 2017 gf Author(https://gitee.com/johng/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://gitee.com/johng/gf. + +// 并发安全的SET +package gset diff --git a/g/database/gdb/gdb.go b/g/database/gdb/gdb.go index 634222c20..48fcbcd82 100644 --- a/g/database/gdb/gdb.go +++ b/g/database/gdb/gdb.go @@ -3,9 +3,8 @@ // 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://gitee.com/johng/gf. -// -// 对常用关系数据库的封装管理包 +// 关系数据库操作 package gdb import ( diff --git a/g/encoding/gbase64/gbase64.go b/g/encoding/gbase64/gbase64.go index fab67b7bc..b3b4500c0 100644 --- a/g/encoding/gbase64/gbase64.go +++ b/g/encoding/gbase64/gbase64.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// BASE64 package gbase64 import ( diff --git a/g/encoding/gbinary/gbinary.go b/g/encoding/gbinary/gbinary.go index cfbd72e5e..16337e98f 100644 --- a/g/encoding/gbinary/gbinary.go +++ b/g/encoding/gbinary/gbinary.go @@ -5,7 +5,6 @@ // You can obtain one at https://gitee.com/johng/gf. // 二进制及byte操作管理包 - package gbinary import ( diff --git a/g/encoding/gcompress/gcompress.go b/g/encoding/gcompress/gcompress.go index a6dc530fa..57633a7eb 100644 --- a/g/encoding/gcompress/gcompress.go +++ b/g/encoding/gcompress/gcompress.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 数据压缩/解压 package gcompress import ( diff --git a/g/encoding/gcrc32/gcrc32.go b/g/encoding/gcrc32/gcrc32.go index 1016608f8..da9124565 100644 --- a/g/encoding/gcrc32/gcrc32.go +++ b/g/encoding/gcrc32/gcrc32.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// CRC32 package gcrc32 import ( diff --git a/g/encoding/ghash/ghash.go b/g/encoding/ghash/ghash.go index 5cc38d09b..61a60d7a1 100644 --- a/g/encoding/ghash/ghash.go +++ b/g/encoding/ghash/ghash.go @@ -4,8 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. -// 封装常用的hash函数 - +// 常用的hash函数 package ghash diff --git a/g/encoding/ghtml/ghtml.go b/g/encoding/ghtml/ghtml.go index a35e33666..ded3f14c8 100644 --- a/g/encoding/ghtml/ghtml.go +++ b/g/encoding/ghtml/ghtml.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// HTML编码 package ghtml import "strings" diff --git a/g/encoding/gjson/gjson.go b/g/encoding/gjson/gjson.go index ea356698c..06fd9a12b 100644 --- a/g/encoding/gjson/gjson.go +++ b/g/encoding/gjson/gjson.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 强大的JSON解析/封装包 package gjson import ( diff --git a/g/encoding/gmd5/gmd5.go b/g/encoding/gmd5/gmd5.go index 77c044b8b..9b7dc1339 100644 --- a/g/encoding/gmd5/gmd5.go +++ b/g/encoding/gmd5/gmd5.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// MD5 package gmd5 import ( diff --git a/g/encoding/gsha1/gsha1.go b/g/encoding/gsha1/gsha1.go index 4324aacf3..051a6c9b4 100644 --- a/g/encoding/gsha1/gsha1.go +++ b/g/encoding/gsha1/gsha1.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// SHA1 package gsha1 import ( diff --git a/g/encoding/gurl/url.go b/g/encoding/gurl/url.go index 40422f376..4faf994f5 100644 --- a/g/encoding/gurl/url.go +++ b/g/encoding/gurl/url.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// URL编码 package gurl import "net/url" diff --git a/g/frame/gcfg/gcfg.go b/g/frame/gcfg/gcfg.go index 2a9b5cbf2..b1f1325f8 100644 --- a/g/frame/gcfg/gcfg.go +++ b/g/frame/gcfg/gcfg.go @@ -5,7 +5,6 @@ // You can obtain one at https://gitee.com/johng/gf. // 全局配置管理对象,配置文件为json文件 - package gcfg import ( diff --git a/g/frame/gins/gins.go b/g/frame/gins/gins.go index 15b9cfd30..6f808888a 100644 --- a/g/frame/gins/gins.go +++ b/g/frame/gins/gins.go @@ -6,7 +6,6 @@ // 单例对象管理工具 // 框架内置了一些核心对象,并且可以通过Set和Get方法实现IoC以及对内置核心对象的自定义替换 - package gins import ( @@ -53,7 +52,7 @@ func View() *gview.View { path = gfile.SelfDir() } } - view := gview.GetView(path) + view := gview.Get(path) Set(FRAME_CORE_COMPONENT_NAME_VIEW, view) return view } diff --git a/g/frame/gmvc/controller.go b/g/frame/gmvc/controller.go index 912637cbc..814a4e531 100644 --- a/g/frame/gmvc/controller.go +++ b/g/frame/gmvc/controller.go @@ -5,7 +5,6 @@ // You can obtain one at https://gitee.com/johng/gf. // MVC控制器基类 - package gmvc import ( diff --git a/g/frame/gmvc/model.go b/g/frame/gmvc/model.go index 56bf58e84..5939daf65 100644 --- a/g/frame/gmvc/model.go +++ b/g/frame/gmvc/model.go @@ -4,8 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. -// 模型基类 - +// MVC模型基类 package gmvc type Model struct { diff --git a/g/frame/gmvc/view.go b/g/frame/gmvc/view.go index 1adad160c..9aa0870cd 100644 --- a/g/frame/gmvc/view.go +++ b/g/frame/gmvc/view.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// MVC视图基类 package gmvc import ( diff --git a/g/net/ghttp/ghttp.go b/g/net/ghttp/ghttp.go new file mode 100644 index 000000000..12192b26a --- /dev/null +++ b/g/net/ghttp/ghttp.go @@ -0,0 +1,8 @@ +// Copyright 2017 gf Author(https://gitee.com/johng/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://gitee.com/johng/gf. + +// 强大的HTTP Client及Server管理包 +package ghttp diff --git a/g/net/ghttp/http_server.go b/g/net/ghttp/http_server.go index 4749e5437..9bc39c610 100644 --- a/g/net/ghttp/http_server.go +++ b/g/net/ghttp/http_server.go @@ -4,7 +4,6 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - package ghttp import ( diff --git a/g/net/gipv4/gipv4.go b/g/net/gipv4/gipv4.go index 375a60ee0..811092e11 100644 --- a/g/net/gipv4/gipv4.go +++ b/g/net/gipv4/gipv4.go @@ -5,6 +5,7 @@ // You can obtain one at https://gitee.com/johng/gf. // +// IPv4管理 package gipv4 import ( diff --git a/g/net/gipv6/gipv6.go b/g/net/gipv6/gipv6.go index f5cb48327..c71df2756 100644 --- a/g/net/gipv6/gipv6.go +++ b/g/net/gipv6/gipv6.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// IPv6管理 package gipv6 import "gitee.com/johng/gf/g/util/gregx" diff --git a/g/net/grouter/grouter.go b/g/net/grouter/grouter.go index 5b351d460..14123f71e 100644 --- a/g/net/grouter/grouter.go +++ b/g/net/grouter/grouter.go @@ -5,6 +5,7 @@ // You can obtain one at https://gitee.com/johng/gf. // +// 路由管理 package grouter import ( @@ -27,7 +28,6 @@ type Router struct { prules *gmap.StringStringMap // 打包规则 } - func New() *Router { return &Router{ drules : gmap.NewStringStringMap(), diff --git a/g/net/gscanner/scanner.go b/g/net/gscanner/scanner.go index e7d331cd1..527eb4b3b 100644 --- a/g/net/gscanner/scanner.go +++ b/g/net/gscanner/scanner.go @@ -5,7 +5,6 @@ // You can obtain one at https://gitee.com/johng/gf. // 局域网端口扫描 - package gscanner import ( diff --git a/g/net/gsmtp/smtp.go b/g/net/gsmtp/smtp.go index a0ce781ec..344bb540f 100644 --- a/g/net/gsmtp/smtp.go +++ b/g/net/gsmtp/smtp.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// SMTP package gsmtp import ( diff --git a/g/net/gtcp/tcp.go b/g/net/gtcp/tcp.go index 589836074..3d7a51d52 100644 --- a/g/net/gtcp/tcp.go +++ b/g/net/gtcp/tcp.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// TCP服务端 package gtcp import ( diff --git a/g/net/gudp/udp.go b/g/net/gudp/udp.go index d8d631caf..455ed4af5 100644 --- a/g/net/gudp/udp.go +++ b/g/net/gudp/udp.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// UDP服务端 package gudp import ( diff --git a/g/os/gcache/gcache.go b/g/os/gcache/gcache.go index 71542e08f..bae9aa6ea 100644 --- a/g/os/gcache/gcache.go +++ b/g/os/gcache/gcache.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 单进程缓存管理 package gcache import ( diff --git a/g/os/gcmd/gcmd.go b/g/os/gcmd/gcmd.go index 8d1c43c21..a86ef2add 100644 --- a/g/os/gcmd/gcmd.go +++ b/g/os/gcmd/gcmd.go @@ -5,6 +5,7 @@ // You can obtain one at https://gitee.com/johng/gf. // +// 命令行管理 package gcmd import ( diff --git a/g/os/genv/genv.go b/g/os/genv/genv.go index 64d2d8f9e..7b413b7bf 100644 --- a/g/os/genv/genv.go +++ b/g/os/genv/genv.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 环境变量管理 package genv import "os" diff --git a/g/os/gfile/gfile.go b/g/os/gfile/gfile.go index f2722b164..179bdae0d 100644 --- a/g/os/gfile/gfile.go +++ b/g/os/gfile/gfile.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 文件管理 package gfile import ( diff --git a/g/os/gfilepool/gfilepool.go b/g/os/gfilepool/gfilepool.go index 3a5d448b3..497d9d020 100644 --- a/g/os/gfilepool/gfilepool.go +++ b/g/os/gfilepool/gfilepool.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 文件指针池 package gfilepool import ( diff --git a/g/os/gfilespace/gfilespace.go b/g/os/gfilespace/gfilespace.go index 1e25941f8..b291c0b01 100644 --- a/g/os/gfilespace/gfilespace.go +++ b/g/os/gfilespace/gfilespace.go @@ -5,8 +5,6 @@ // You can obtain one at https://gitee.com/johng/gf. // 文件空间管理, 可用于文件碎片空间维护及再利用,支持自动合并连续碎片空间 - - package gfilespace import ( diff --git a/g/os/gtime/time.go b/g/os/gtime/time.go index 45e102710..5973e35fa 100644 --- a/g/os/gtime/time.go +++ b/g/os/gtime/time.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 时间管理 package gtime import ( @@ -25,9 +25,8 @@ func SetInterval(t time.Duration, callback func() bool) { go func() { for { time.Sleep(t) - r := callback() - if !r { - break; + if !callback() { + break } } }() diff --git a/g/os/gview/gview.go b/g/os/gview/gview.go index 6ae5474c4..e1f82cf0a 100644 --- a/g/os/gview/gview.go +++ b/g/os/gview/gview.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 视图管理 package gview import ( @@ -38,7 +38,7 @@ type Template struct { var viewMap = gmap.NewStringInterfaceMap() // 获取或者创建一个视图对象 -func GetView(path string) *View { +func Get(path string) *View { if r := viewMap.Get(path); r != nil { return r.(*View) } @@ -49,7 +49,7 @@ func GetView(path string) *View { // 生成一个视图对象 func New(path string) *View { - return &View{ + return &View { path : path, tpls : gmap.NewStringInterfaceMap(), suffix : "tpl", diff --git a/g/util/grand/rand.go b/g/util/grand/rand.go index 765bb3cc1..ab13fc387 100644 --- a/g/util/grand/rand.go +++ b/g/util/grand/rand.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 随机数管理 package grand import ( diff --git a/g/util/gregx/regx.go b/g/util/gregx/regx.go index c8729fb42..2ea89c49c 100644 --- a/g/util/gregx/regx.go +++ b/g/util/gregx/regx.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 正则表达式 package gregx import ( diff --git a/g/util/gutil/gutil.go b/g/util/gutil/gutil.go index 900a08eae..22471e3d8 100644 --- a/g/util/gutil/gutil.go +++ b/g/util/gutil/gutil.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://gitee.com/johng/gf. - +// 其他工具包 package gutil // 便利数组查找字符串索引位置,如果不存在则返回-1 diff --git a/g/util/gvalid/gvalid.go b/g/util/gvalid/gvalid.go index d8ad8c4ab..af56c5d7d 100644 --- a/g/util/gvalid/gvalid.go +++ b/g/util/gvalid/gvalid.go @@ -3,7 +3,7 @@ // 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://gitee.com/johng/gf. -// + // 通用数据验证工具 // 本来打算取名gvalidator的,名字太长了,缩写一下 /* @@ -50,7 +50,6 @@ in 格式:in:value1,value2,... 说明:参 not-in 格式:not-in:value1,value2,... 说明:参数值不应该在value1,value2,...中(字符串匹配) regex 格式:regex:pattern 说明:参数值应当满足正则匹配规则pattern */ - package gvalid import (