From f3a208f02f98a6761be3303d10fe80f768563d7f Mon Sep 17 00:00:00 2001 From: John Date: Wed, 8 Jan 2020 20:00:42 +0800 Subject: [PATCH] fix issue in router value retrieving for ghttp.Request --- .example/other/test.go | 18 +++++++++--------- net/ghttp/ghttp_request_param_router.go | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.example/other/test.go b/.example/other/test.go index 09942dd5c..e9d54731a 100644 --- a/.example/other/test.go +++ b/.example/other/test.go @@ -1,14 +1,14 @@ package main -import "fmt" +import ( + "github.com/gogf/gf/frame/g" + "github.com/gogf/gf/os/gfile" +) func main() { - type User struct { - Id int - } - u1 := &User{1} - u2 := *u1 - u2.Id = 2 - fmt.Println(u1) - fmt.Println(u2) + g.Dump(gfile.ScanDirFile("/Users/john/Temp/test", "*", true)) + //if err := gfile.ReplaceDir("gf-empty", "app", "/Users/john/Temp/test", "*.*", true); err != nil { + // glog.Fatal("content replacing failed,", err.Error()) + //} + } diff --git a/net/ghttp/ghttp_request_param_router.go b/net/ghttp/ghttp_request_param_router.go index f1d7d44f0..25b55f81f 100644 --- a/net/ghttp/ghttp_request_param_router.go +++ b/net/ghttp/ghttp_request_param_router.go @@ -12,7 +12,9 @@ import "github.com/gogf/gf/container/gvar" // It returns if does not exist. func (r *Request) GetRouterValue(key string, def ...interface{}) interface{} { if r.routerMap != nil { - return r.routerMap[key] + if v, ok := r.routerMap[key]; ok { + return v + } } if len(def) > 0 { return def[0]