当我使用gorilla/rpc/json时,如何为参数设置空值?

当我使用gorilla/rpc/json时,如何为参数设置空值?,go,json-rpc,gorilla,Go,Json Rpc,Gorilla,我试图向RPC接口发送请求,但该接口不需要参数。这意味着params字段应该是“params”:[],但是当我使用json.EncodeClientRequest(方法字符串,args接口{})时,params的值总是“params”:[{}]或“params”:[null]。因此它总是导致错误:map[code:-32602消息:无效的方法参数]。如何为参数设置空值。接下来是我的请求结构: // request struct type JsonRpcReq struct { Id

我试图向RPC接口发送请求,但该接口不需要参数。这意味着params字段应该是
“params”:[]
,但是当我使用
json.EncodeClientRequest(方法字符串,args接口{})
时,params的值总是
“params”:[{}]
“params”:[null]
。因此它总是导致错误:
map[code:-32602消息:无效的方法参数]
。如何为参数设置空值。接下来是我的请求结构:

// request struct
type JsonRpcReq struct {
    Id      uint32       `json:"id"`
    Url     string       `json:"url"`
    Method  string       `json:"method"`
    Params  *interface{} `json:"params"`
    JsonRpc string       `json:"jsonrpc"`
}
句子的错误是:

// request method
func (r *JsonRpcReq) Send() (interface{}, error) {
    message, err := json.EncodeClientRequest(r.Method, r.Params)
    fmt.Println(string(message))
    if err != nil {
        return nil, err
    }
    ...
}
请求的句子是:

req := NewJsonRpcReq("http://finance.test.cppp.com/rpc/healthCheck", "status", nil)
NewJsonRpcReq
方法是:

func NewJsonRpcReq(url, method string, params *interface{}) *JsonRpcReq {
    return &JsonRpcReq{Id: 0, Url: url, Method: method, Params: params, JsonRpc: "2.0"}
}

尝试使用
[]字符串{}
调用
NewJsonRpcReq
,而不是
nil
interface{}{}
我刚才尝试过,但内容是
{“方法”:“状态”,“参数”:[[]],“id”:5577006791947779410}
,它仍然会引发相同的错误。您是控制
JsonRpcReq
的定义还是生成的某种代码?