We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
测试环境: macOS 10.13.6 golang 1.10
自己在做测试的时候发现如果请求参数中有int类型参数的话,钉钉接口就会报错。原因是受到参数类型转换方式的影响。
SDK中将interface{}转换为string类型的方式为:fmt.Sprintf("%s", v),这种方式将int类型的参数转换为string类型,然后再组合到请求参数时,会带附加字符。钉钉服务器参数值验证不通过。具体位置为: request.go 146行和181行。
使用自己的类型转换方法之后,测试通过。
具体参数类型转换方法:
`func String(args ...interface{}) string { value := args[0] var precision int = 12
switch value.(type) { case string: v, _ := value.(string) return v case int: v, _ := value.(int) return strconv.Itoa(v) case int32: v, _ := value.(int32) return strconv.FormatInt(int64(v), 10) case int64: v, _ := value.(int64) return strconv.FormatInt(v, 10) case float32: v, _ := value.(float32) if len(args) >= 2 { precision = args[1].(int) } return strconv.FormatFloat(float64(v), 'f', precision, 64) case float64: v, _ := value.(float64) if len(args) >= 2 { precision = args[1].(int) } return strconv.FormatFloat(v, 'f', precision, 64) case template.HTML: return string(value.(template.HTML)) default: return "" }
}`
The text was updated successfully, but these errors were encountered:
可以发个PR
Sorry, something went wrong.
No branches or pull requests
测试环境:
macOS 10.13.6
golang 1.10
自己在做测试的时候发现如果请求参数中有int类型参数的话,钉钉接口就会报错。原因是受到参数类型转换方式的影响。
SDK中将interface{}转换为string类型的方式为:fmt.Sprintf("%s", v),这种方式将int类型的参数转换为string类型,然后再组合到请求参数时,会带附加字符。钉钉服务器参数值验证不通过。具体位置为:
request.go 146行和181行。
使用自己的类型转换方法之后,测试通过。
具体参数类型转换方法:
`func String(args ...interface{}) string {
value := args[0]
var precision int = 12
}`
The text was updated successfully, but these errors were encountered: