Mount local FS; get struct pointer so we can modify values
This commit is contained in:
17
cmd/list.go
17
cmd/list.go
@ -16,13 +16,13 @@ import (
|
||||
|
||||
// Recurse into structure, returning reflect.Value of wanted field.
|
||||
// Nested fields are named with a dot (ex "MyStruct.MyField")
|
||||
func getStructFieldValue(parentStruct interface{}, fieldName string) (reflect.Value, string, error) {
|
||||
func getStructFieldValue(parentStruct interface{}, fieldName string) (*reflect.Value, string, error) {
|
||||
v := reflect.ValueOf(parentStruct)
|
||||
|
||||
if v.Kind() == reflect.Ptr {
|
||||
/* if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
*/
|
||||
if false {
|
||||
for i := 0 ; i < v.NumField(); i++ {
|
||||
f := v.Field(i)
|
||||
@ -34,7 +34,8 @@ func getStructFieldValue(parentStruct interface{}, fieldName string) (reflect.Va
|
||||
|
||||
if strings.Contains(fieldName, ".") {
|
||||
fs := strings.Split(fieldName, ".")
|
||||
f := v.FieldByName(fs[0])
|
||||
//f := v.FieldByName(fs[0])
|
||||
f := v.Elem().FieldByName(fs[0])
|
||||
if f.Kind() == reflect.Struct {
|
||||
return getStructFieldValue(f.Interface(), strings.Join(fs[1:], "."))
|
||||
} else {
|
||||
@ -43,13 +44,13 @@ func getStructFieldValue(parentStruct interface{}, fieldName string) (reflect.Va
|
||||
} else {
|
||||
f := v.FieldByName(fieldName)
|
||||
if f.IsValid() {
|
||||
return f, fieldName, nil
|
||||
return &f, fieldName, nil
|
||||
} else {
|
||||
return v, fieldName, errors.New(fmt.Sprintf("Field not found: %s", fieldName))
|
||||
return &v, fieldName, errors.New(fmt.Sprintf("Field not found: %s", fieldName))
|
||||
}
|
||||
}
|
||||
|
||||
return v, fieldName, nil
|
||||
return &v, fieldName, nil
|
||||
}
|
||||
|
||||
|
||||
@ -365,7 +366,7 @@ func ListJails(args []string, display bool) {
|
||||
js := initSortStruct()
|
||||
|
||||
// The way we manage criteria quantity is not very elegant...
|
||||
var fct1, fct2, fct3 reflect.Value
|
||||
var fct1, fct2, fct3 *reflect.Value
|
||||
for i, c := range strings.Split(gSortFields, ",") {
|
||||
var fctName string
|
||||
if strings.HasPrefix(c, "-") {
|
||||
|
||||
Reference in New Issue
Block a user