亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在接口上調用 len()?

如何在接口上調用 len()?

Go
開心每一天1111 2021-07-07 09:05:16
我正在編寫一個 JSON 列表為空的測試。{"matches": []}該對象具有 type map[string]interface{},我想測試該列表是否為空。var matches := response["matches"]if len(matches) != 0 {    t.Errorf("Non-empty match list!")}但是我在編譯時被告知這是無效的invalid argument matches (type interface {}) for len如果我嘗試轉換為列表類型:matches := response["matches"].([]string)我感到恐慌:panic: interface conversion: interface is []interface {}, not []string [recovered]我想在這里寫什么?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號