From 6f88fee9ab3749c4da4b3a09dea3ae124830dc19 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 23 Aug 2018 15:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgarray=E9=94=81=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/container/garray/garray_int.go | 12 ++++++------ geg/net/ghttp/server/hello.go | 2 +- geg/other/test.go | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/g/container/garray/garray_int.go b/g/container/garray/garray_int.go index ba0650506..1b464899b 100644 --- a/g/container/garray/garray_int.go +++ b/g/container/garray/garray_int.go @@ -48,14 +48,14 @@ func (a *IntArray) Get(index int) int { // 设置指定索引的数据项, 调用方注意判断数组边界 func (a *IntArray) Set(index int, value int) { a.mu.Lock() - defer a.mu.RUnlock() + defer a.mu.Unlock() a.array[index] = value } // 在当前索引位置前插入一个数据项, 调用方注意判断数组边界 func (a *IntArray) Insert(index int, value int) { a.mu.Lock() - defer a.mu.RUnlock() + defer a.mu.Unlock() rear := append([]int{}, a.array[index : ]...) a.array = append(a.array[0 : index], value) a.array = append(a.array, rear...) @@ -65,14 +65,14 @@ func (a *IntArray) Insert(index int, value int) { // 删除指定索引的数据项, 调用方注意判断数组边界 func (a *IntArray) Remove(index int) { a.mu.Lock() - defer a.mu.RUnlock() + defer a.mu.Unlock() a.array = append(a.array[ : index], a.array[index + 1 : ]...) } // 追加数据项 func (a *IntArray) Append(value int) { a.mu.Lock() - defer a.mu.RUnlock() + defer a.mu.Unlock() a.array = append(a.array, value) } @@ -95,7 +95,7 @@ func (a *IntArray) Slice() []int { // 清空数据数组 func (a *IntArray) Clear() { a.mu.Lock() - defer a.mu.RUnlock() + defer a.mu.Unlock() if a.cap > 0 { a.array = make([]int, a.size, a.cap) } else { @@ -148,6 +148,6 @@ func (a *IntArray) LockFunc(f func(array []int)) { // 使用自定义方法执行加锁读取操作 func (a *IntArray) RLockFunc(f func(array []int)) { a.mu.RLock() - defer a.mu.Unlock() + defer a.mu.RUnlock() f(a.array) } \ No newline at end of file diff --git a/geg/net/ghttp/server/hello.go b/geg/net/ghttp/server/hello.go index 9f95af03d..be6bc7c4f 100644 --- a/geg/net/ghttp/server/hello.go +++ b/geg/net/ghttp/server/hello.go @@ -8,7 +8,7 @@ import ( func main() { s := g.Server() s.BindHandler("/", func(r *ghttp.Request){ - r.Response.Writeln(r.GetInt("id")) + r.Response.Writeln("哈喽世界!") }) s.SetPort(8199) s.Run() diff --git a/geg/other/test.go b/geg/other/test.go index d4e1af3ce..8a734dcc6 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -1,15 +1,15 @@ package main import ( - "gitee.com/johng/gf/g" + "gitee.com/johng/gf/g/util/gregex" "fmt" ) func main() { - v := g.View() - v.AddPath("/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/geg/other") - b, e := v.Parse("index.html") - fmt.Println(e) - fmt.Println(string(b)) + s := `百度"` + gregex.ReplaceStringFunc(`href="(.+?)"`, s, func(s string) string { + fmt.Println(s) + return s + }) } \ No newline at end of file