对这种 [class news name age] 返回什么类型啊

hellsam · · 1046 次点击
你说的"API返回的是[class news name age]",是不是你print出来的? 结构体对象打印默认格式就是这样的,只会打印属性值。 你是否能拿到结构体定义? 或者你用sprintf打印出结构体具体属性信息,或者干脆转成json看一下结构 给的信息有的少,不好判断
#3
更多评论
说实话,不明白你在说啥,能多提供些上下文信息吗
#1
~~~ <a href="/user/channel" title="@channel">@channel</a> API返回的是[class news name age] 这种类型 还是必须只能用interface{} 接收,用字符串就报错了 无奈啊, 不知道如何处理了。 这样一个条件也不满足了 type TaskTest int const ( _ TaskTest = iota a b c ) func main() { var ss2 TaskTest ss2, _ = GetStatus() fmt.Println(ss2) //结果我这里永远都是返回0 , switch永远不匹配 } func GetStatus() (status TaskTest, err error) { result := &#34;b&#34; //这个我固定了,默认是API地址 我以为返回一个字符 如a b c结果返回如:[class news name age] //是一个 interface{} 也无法转换string switch result { case &#34;a&#34;: status = a case &#34;b&#34;: status = b case &#34;c&#34;: status = c } return status ,nil } ~~~
#2