From 9bb1125169273e4283d72233d4fbf43c354dae6b Mon Sep 17 00:00:00 2001 From: john Date: Fri, 19 Oct 2018 17:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0go=20modules=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../server/performance/beego/beegoRule.go | 14 ------- .../server/performance/beego/beegoStatic.go | 14 ------- geg/net/ghttp/server/performance/client.go | 40 ------------------- geg/net/ghttp/server/performance/gf/gfRule.go | 15 ------- .../ghttp/server/performance/gf/gfStatic.go | 16 -------- .../ghttp/server/performance/gin/ginRule.go | 16 -------- .../ghttp/server/performance/gin/ginStatic.go | 16 -------- go.mod | 37 +++++++++++++++++ 9 files changed, 38 insertions(+), 131 deletions(-) delete mode 100644 geg/net/ghttp/server/performance/beego/beegoRule.go delete mode 100644 geg/net/ghttp/server/performance/beego/beegoStatic.go delete mode 100644 geg/net/ghttp/server/performance/client.go delete mode 100644 geg/net/ghttp/server/performance/gf/gfRule.go delete mode 100644 geg/net/ghttp/server/performance/gf/gfStatic.go delete mode 100644 geg/net/ghttp/server/performance/gin/ginRule.go delete mode 100644 geg/net/ghttp/server/performance/gin/ginStatic.go create mode 100644 go.mod diff --git a/.gitignore b/.gitignore index 644a56cf8..679820f45 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ bin/ cbuild */.DS_Store .vscode/ +go.sum diff --git a/geg/net/ghttp/server/performance/beego/beegoRule.go b/geg/net/ghttp/server/performance/beego/beegoRule.go deleted file mode 100644 index 12778850d..000000000 --- a/geg/net/ghttp/server/performance/beego/beegoRule.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "github.com/astaxie/beego" - "github.com/astaxie/beego/context" -) - -func main() { - beego.Get("/:name",func(ctx *context.Context){ - ctx.Output.Body([]byte(ctx.Input.Param(":name"))) - }) - beego.BeeLogger.SetLevel(0) - beego.Run(":8199") -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/beego/beegoStatic.go b/geg/net/ghttp/server/performance/beego/beegoStatic.go deleted file mode 100644 index 7460b2d54..000000000 --- a/geg/net/ghttp/server/performance/beego/beegoStatic.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "github.com/astaxie/beego" - "github.com/astaxie/beego/context" -) - -func main() { - beego.Get("/",func(ctx *context.Context){ - ctx.Output.Body([]byte("哈喽世界!")) - }) - beego.BeeLogger.SetLevel(0) - beego.Run(":8199") -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/client.go b/geg/net/ghttp/server/performance/client.go deleted file mode 100644 index 4955f222a..000000000 --- a/geg/net/ghttp/server/performance/client.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import ( - "fmt" - "sync" - "gitee.com/johng/gf/g/os/gtime" - "gitee.com/johng/gf/g/net/ghttp" - "gitee.com/johng/gf/g/container/gtype" -) - -func main() { - clientMax := 1000 - requestMax := 1000 - failureNum := gtype.NewInt64() - successNum := gtype.NewInt64() - startTime := gtime.Millisecond() - - wg := sync.WaitGroup{} - for i := 0; i < clientMax; i++ { - wg.Add(1) - go func(clientId int) { - url := "http://127.0.0.1:8199/" - for i := 0; i < requestMax; i++ { - //url = fmt.Sprintf("http://127.0.0.1:8199/%d_%d", clientId, i) - if c, e := ghttp.Get(url); e == nil { - c.Close() - successNum.Add(1) - } else { - fmt.Println(e) - failureNum.Add(1) - } - } - wg.Done() - }(i) - } - wg.Wait() - - fmt.Printf("time spent: %d ms, success:%d, failure: %d\n", - gtime.Millisecond() - startTime, successNum.Val(), failureNum.Val()) -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/gf/gfRule.go b/geg/net/ghttp/server/performance/gf/gfRule.go deleted file mode 100644 index 0ad723f77..000000000 --- a/geg/net/ghttp/server/performance/gf/gfRule.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "gitee.com/johng/gf/g" - "gitee.com/johng/gf/g/net/ghttp" -) - -func main() { - s := g.Server() - s.BindHandler("/:name", func(r *ghttp.Request){ - r.Response.Write(r.Get("name")) - }) - s.SetPort(8199) - s.Run() -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/gf/gfStatic.go b/geg/net/ghttp/server/performance/gf/gfStatic.go deleted file mode 100644 index 3b6c7ec36..000000000 --- a/geg/net/ghttp/server/performance/gf/gfStatic.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "gitee.com/johng/gf/g" - "gitee.com/johng/gf/g/net/ghttp" -) - -func main() { - s := g.Server() - s.BindHandler("/", func(r *ghttp.Request){ - r.Response.Write("哈喽世界!") - }) - s.EnablePprof() - s.SetPort(8199) - s.Run() -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/gin/ginRule.go b/geg/net/ghttp/server/performance/gin/ginRule.go deleted file mode 100644 index 791eecc73..000000000 --- a/geg/net/ghttp/server/performance/gin/ginRule.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "net/http" - "github.com/gin-gonic/gin" -) - -func main() { - gin.SetMode(gin.ReleaseMode) - r := gin.New() - r.Use(gin.Recovery()) - r.GET("/:name", func(c *gin.Context) { - c.String(http.StatusOK, c.Param("name")) - }) - r.Run(":8199") -} \ No newline at end of file diff --git a/geg/net/ghttp/server/performance/gin/ginStatic.go b/geg/net/ghttp/server/performance/gin/ginStatic.go deleted file mode 100644 index ee43d35a4..000000000 --- a/geg/net/ghttp/server/performance/gin/ginStatic.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "net/http" - "github.com/gin-gonic/gin" -) - -func main() { - gin.SetMode(gin.ReleaseMode) - r := gin.New() - r.Use(gin.Recovery()) - r.GET("/", func(c *gin.Context) { - c.String(http.StatusOK, "哈喽世界!") - }) - r.Run(":8199") -} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..4b7603615 --- /dev/null +++ b/go.mod @@ -0,0 +1,37 @@ +module gitee.com/johng/gf + +require ( + github.com/BurntSushi/toml v0.3.1 + github.com/Shopify/sarama v1.19.0 + github.com/Shopify/toxiproxy v2.1.3+incompatible // indirect + github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 + github.com/clbanning/mxj v1.8.2 + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/eapache/go-resiliency v1.1.0 // indirect + github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect + github.com/eapache/queue v1.1.0 // indirect + github.com/fatih/structs v1.1.0 + github.com/fsnotify/fsnotify v1.4.7 + github.com/ghodss/yaml v1.0.0 + github.com/go-sql-driver/mysql v1.4.0 + github.com/gofrs/flock v0.7.0 // indirect + github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect + github.com/gomodule/redigo v2.0.0+incompatible + github.com/gorilla/websocket v1.4.0 + github.com/grokify/html-strip-tags-go v0.0.0-20180907063347-e9e44961e26f + github.com/kr/pretty v0.1.0 // indirect + github.com/mattn/go-runewidth v0.0.3 // indirect + github.com/olekukonko/tablewriter v0.0.0-20180912035003-be2c049b30cc + github.com/pierrec/lz4 v2.0.5+incompatible // indirect + github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect + github.com/theckman/go-flock v0.7.0 + golang.org/x/sys v0.0.0 + gopkg.in/check.v1 v1.0.0 + gopkg.in/yaml.v2 v2.2.1 +) + +replace ( + golang.org/x/sys => ./vendor/golang.org/x/sys + gopkg.in/check.v1 => ./vendor/gopkg.in/check.v1 + gopkg.in/yaml.v2 => ./vendor/gopkg.in/yaml.v2 +)