From 899fcbf2dabf76b288ccac8edf063a7071d1528b Mon Sep 17 00:00:00 2001 From: john Date: Thu, 4 Jun 2020 17:55:43 +0800 Subject: [PATCH] add mor example for package garray --- .example/other/config.toml | 25 -------------------- .example/other/test.go | 20 ---------------- .example/other/test2.go | 11 --------- container/garray/garray_z_example_test.go | 28 +++++++++++++++++++++++ 4 files changed, 28 insertions(+), 56 deletions(-) delete mode 100644 .example/other/config.toml delete mode 100644 .example/other/test.go delete mode 100644 .example/other/test2.go diff --git a/.example/other/config.toml b/.example/other/config.toml deleted file mode 100644 index 035f005c4..000000000 --- a/.example/other/config.toml +++ /dev/null @@ -1,25 +0,0 @@ - -[database] - debug = true - link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test" - -[redis] - default = "127.0.0.1:6379,0" - cache = "127.0.0.1:6379,1" - -# Logger. -[logger] - Path = "/tmp/log/gf-app" - Level = "all" - Stdout = true - -[viewer] - delimiters = ["${", "}"] - autoencode = true - - -[server] - Address = ":8800" - ServerRoot = "/Users/john/Downloads" - ServerAgent = "gf-app" -# LogPath = "./log/gf-app/server" \ No newline at end of file diff --git a/.example/other/test.go b/.example/other/test.go deleted file mode 100644 index f590bf262..000000000 --- a/.example/other/test.go +++ /dev/null @@ -1,20 +0,0 @@ -package main - -import ( - "github.com/gogf/gf/frame/g" - "github.com/gogf/gf/net/ghttp" -) - -func main() { - s := g.Server() - s.BindHandler("POST:/login", func(r *ghttp.Request) { - r.Response.Write("login handler") - }) - s.Group("/", func(group *ghttp.RouterGroup) { - group.GET("/test", func(r *ghttp.Request) { - r.Response.Write("for authenticated handler testing") - }) - }) - s.SetPort(8199) - s.Run() -} diff --git a/.example/other/test2.go b/.example/other/test2.go deleted file mode 100644 index dbb538a46..000000000 --- a/.example/other/test2.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "github.com/gogf/gf/frame/g" -) - -func main() { - s := g.Server() - s.SetIndexFolder(true) - s.Run() -} diff --git a/container/garray/garray_z_example_test.go b/container/garray/garray_z_example_test.go index 2dbe37d8c..cf234071e 100644 --- a/container/garray/garray_z_example_test.go +++ b/container/garray/garray_z_example_test.go @@ -101,6 +101,34 @@ func Example_popItem() { // [7 8] } +func Example_walk() { + var array garray.StrArray + tables := g.SliceStr{"user", "user_detail"} + prefix := "gf_" + array.Append(tables...) + // Add prefix for given table names. + array.Walk(func(value string) string { + return prefix + value + }) + fmt.Println(array.Slice()) + + // Output: + // [gf_user gf_user_detail] +} + +func Example_contains() { + var array garray.StrArray + array.Append("a") + fmt.Println(array.Contains("a")) + fmt.Println(array.Contains("A")) + fmt.Println(array.ContainsI("A")) + + // Output: + // true + // false + // true +} + func Example_mergeArray() { array1 := garray.NewFrom([]interface{}{1, 2}) array2 := garray.NewFrom([]interface{}{3, 4})