//遍历结构体的属性和对应值,返回字符串 func GetStringOfStruct(obj interface{})string{ t := reflect.TypeOf(obj) v := reflect.ValueOf(obj) res := "" for k := 0; k < t.NumField(); k++{ tmp:=fmt.Sprintf("%s: %v ", t.Field(k).Name, v.Field(k).Interface()) res+=tmp } return res }