gofmt code

This commit is contained in:
easonlin 2017-06-13 00:27:38 +08:00
parent 53799774f4
commit d425bf52b6
3 changed files with 5 additions and 6 deletions

View File

@ -152,7 +152,7 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
if timeFormat == "" {
return errors.New("Blank time format")
}
if val == "" {
value.Set(reflect.ValueOf(time.Time{}))
return nil

View File

@ -87,7 +87,7 @@ func (c *Context) HandlerName() string {
// Handler returns the main handler.
func (c *Context) Handler() HandlerFunc {
return c.handlers.Last()
return c.handlers.Last()
}
/************************************/

View File

@ -283,13 +283,12 @@ var handlerTest HandlerFunc = func(c *Context) {
}
func TestContextHandler(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.handlers = HandlersChain{func(c *Context) {}, handlerTest}
c, _ := CreateTestContext(httptest.NewRecorder())
c.handlers = HandlersChain{func(c *Context) {}, handlerTest}
assert.Equal(t, reflect.ValueOf(handlerTest).Pointer(), reflect.ValueOf(c.Handler()).Pointer())
assert.Equal(t, reflect.ValueOf(handlerTest).Pointer(), reflect.ValueOf(c.Handler()).Pointer())
}
func TestContextQuery(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("GET", "http://example.com/?foo=bar&page=10&id=", nil)