From c8a5281863c2997c9d4080e394eab4abbcd154c9 Mon Sep 17 00:00:00 2001 From: Eason Lin Date: Wed, 10 Jul 2019 11:03:53 +0800 Subject: [PATCH] fix: variables in the assignment caused compile error (#446) --- example/basic/api/api.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/example/basic/api/api.go b/example/basic/api/api.go index 29aca9e10..3709ff5d3 100644 --- a/example/basic/api/api.go +++ b/example/basic/api/api.go @@ -18,8 +18,13 @@ import ( // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] func GetStringByInt(c *gin.Context) { - _ := web.Pet{} - //write your code + var pet web.Pet + if err := c.ShouldBindJSON(&pet); err != nil { + // write your code + return + } + + // write your code } // GetStructArrayByString example @@ -35,7 +40,7 @@ func GetStringByInt(c *gin.Context) { // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-struct-array-by-string/{some_id} [get] func GetStructArrayByString(c *gin.Context) { - //write your code + // write your code } // Upload example @@ -50,7 +55,7 @@ func GetStructArrayByString(c *gin.Context) { // @Failure 404 {object} web.APIError "Can not find ID" // @Router /file/upload [post] func Upload(ctx *gin.Context) { - //write your code + // write your code } // AnonymousField example