草庐IT

valueField

全部标签

go - 在 Go 中递归打印 map 中的所有值

假设我有一张这种类型的map:varresultsmap[string]interface{}值可以是任何东西,甚至是另一张map。我将如何打印所有值?如果该值是一个数组,我想单独打印数组中的每个项目。如果是另一张map,我想在map上递归调用同一个函数。 最佳答案 前段时间我无耻地从网站上撕下了这个:import("fmt""reflect""strings")/*InspectStructprintsthegutsofaninstantiatedstruct.Veryhandyfordebuggingusage:InspectS