英文:
Return empty array from map instead of array with empty string
问题
我有一个将ID映射到字符串数组的映射表,如下所示:accountIDs := make(map[int64][]string, 0)
,在我的响应中,它看起来像这样:
"AccountIDs": {
"1": [
"19565",
"21423"
],
"7": [
""
]
}
如何返回一个空数组而不是一个包含空字符串的数组?
英文:
I have a map of ids that map to an array of strings as such accountIDs := make(map[int64][]string, 0)
and in my response this looks like:
"AccountIDs": {
"1": [
"19565",
"21423"
],
"7": [
""
]
}
How can I return an empty array instead of an array of empty string?
答案1
得分: 1
将值设置为[]string{}
。
myMap[7] = []string{}
请参见Playground
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论