wenerme/go-req

When QueryStirng param is Int type,values such as 1000018, do request will convert to 1.000018e+06

Closed this issue · 2 comments

An incorrect conversion will cause the request to fail.

@lvxuan263 can you give a Req demo , which QueryString you are reference to ?

package wecom

import (
	"github.com/wenerme/go-req"
	gowecom "github.com/wenerme/go-wecom/wecom"
)

type GetAgentRequest struct {
	gowecom.GetAgentRequest
	AgentID string `json:"agentid"`
}

func GetAgent(r *GetAgentRequest, opts ...interface{}) (out gowecom.GetAgentResponse, err error) {
	err = appClient.Request.With(req.Request{
		Method: "GET",
		URL:    "/cgi-bin/agent/get",
		Query:  r,
	}).Fetch(&out)
	return
}

appClient : *gowecom.Client
gowecom.GetAgentRequest 中的agentid为int类型,在req.Request 设置为QueryString Param后,发请求时会被转换为字符串 "1.000018e+06",导致企微接口报错。我之前临时把agentid覆盖成string类型,保证请求成功