代码拉取完成,页面将自动刷新
package mysqlgo
import (
"reflect"
)
type field struct {
names []string
values []interface{}
}
func (f *field) parseData(data interface{}) {
keys, value := f.parseInterface(data)
f.names, f.values = keys, value
}
func (f *field) parseDatas(datas ...interface{}) ([][]interface{}, error) {
if len(datas) == 0 {
return nil, GetError(DataNull)
}
data := datas[0]
var values [][]interface{}
keys, value := f.parseInterface(data)
f.names = keys
values = append(values, value)
for i := 1 ; i < len(datas); i++ {
if !reflect.DeepEqual(data, datas[i]) {
return nil, GetError(TypeError)
}
_, value := f.parseInterface(datas[i])
values = append(values, value)
}
return values, nil
}
func (f *field) parseInterface(data interface{}) (keys []string, values []interface{}) {
getType := reflect.TypeOf(data)
getValue := reflect.ValueOf(data)
for i := 0; i < getType.NumField(); i ++ {
keys = append(keys, getType.Field(i).Name)
values = append(values, getValue.Field(i).Interface())
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。