This is a creation in Article, where the information may have evolved or changed.
1. When you spell a string, the following syntax will cause an error:
Mismatched types string and int
Func geterrorjsondata (status int, msg string) string {jsons: = "{\" status\ ":" +status+ ", \" message\ ": \" "+ msg +" \ "}" Retu RN Jsons}
The correct wording is: need to introduce " StrConvThe package
Func geterrorjsondata (status int, msg string) string {jsons: = "{\" status\ ":" + StrConv. Itoa (status) + ", \" message\ ": \" "+ msg +" \ "}" return jsons}
2. Reflection Type Comparison
var user map[string]interface{}
<pre name= "code" class= "HTML" >user["username"] get the parameters in the map
Reflect. TypeOf (user["username"])//Get the type in map
Reflect. TypeOf (user["username"]) ==reflect. string//matches string, success is true, otherwise false
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.