什么是将结构转储到提供的csv文件中的惯用golang方法?我在一个func里面,我的结构以接口{}传递:将struct写入csv文件
func decode_and_csv(my_response *http.Response, my_struct interface{})
为什么interface {}? - 从JSON中读取数据,可能会返回一些不同的结构,因此试图编写一个足够通用的函数。
我的类型的例子:
type Location []struct {
Name string `json: "Name"`
Region string `json: "Region"`
Type string `json: "Type"`
}