登录
首页 >  Golang >  Go问答

提取rest.response中的数值

来源:stackoverflow

时间:2024-03-06 21:24:27 385浏览 收藏

小伙伴们有没有觉得学习Golang很有意思?有意思就对了!今天就给大家带来《提取rest.response中的数值》,以下内容将会涉及到,若是在学习中对其中部分知识点有疑问,或许看了本文就能帮到你!

问题内容

我收到一个函数返回的rest.response,并希望使用两个返回字段将自定义数据发送到另一个服务。

var reply email.sendtemplateresponsebody

    response, err := s.dynamictemplateemail(request)

    if err != nil {
        reply = email.sendtemplateresponsebody{
                status: int32(response.statuscode),
                message: "it didn't work",
            }
    } else {
        reply = email.sendtemplateresponsebody{
                status:  int32(response.statuscode),
                message: "it worked!",
            }
        }

我正在对字段使用验证,因此想要从正文中获取返回的错误并在上面的代码中使用它。

“回应”:

{StatusCode:400 Body:{"errors":[{"message":"The from object must be provided for every email send. It is an object that requires the email parameter, but may also contain a name parameter.  e.g. {\"email\" : \"[email protected]\"}

这可以在不解组的情况下完成吗?如果是这样,这是正确的方法吗?


解决方案


这可以在不解组的情况下完成吗?

没有。

以上就是《提取rest.response中的数值》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>