2020-01-11 10:58:46 -09:00
|
|
|
package persistence
|
|
|
|
|
|
2020-01-12 13:32:06 -09:00
|
|
|
import "reflect"
|
|
|
|
|
|
2020-01-14 14:23:29 -09:00
|
|
|
func collectField(collection interface{}, getValue func(item interface{}) string) []string {
|
2020-01-12 13:32:06 -09:00
|
|
|
s := reflect.ValueOf(collection)
|
|
|
|
|
result := make([]string, s.Len())
|
|
|
|
|
|
|
|
|
|
for i := 0; i < s.Len(); i++ {
|
|
|
|
|
result[i] = getValue(s.Index(i).Interface())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
}
|