草庐IT

responseResult

全部标签

go - 如何在 Golang 中将不同类型的结构作为参数传递给函数

我有一个将http响应json解码为结构的函数。我有两种类型的结构需要传递给此函数,并将结构类型作为返回值以获取解码的json。我的函数现在可以处理一种类型,需要帮助才能处理不同类型的结构,并返回该结构。//ResponsejsontyperesponseResultstruct{resultstring}typeloginResultstruct{responseResulttokenstring}funcresponseBodyDecoder(resphttp.Response,response*responseResult){//getresultformResponsedeco