fix command line exclude column
This commit is contained in:
parent
bef2e35e41
commit
7fff2f8a1c
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.nspix.com/golang/kos/util/arrays"
|
||||||
"git.nspix.com/golang/kos/util/pool"
|
"git.nspix.com/golang/kos/util/pool"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -184,6 +185,7 @@ func serializeArray(val []any) (buf []byte, err error) {
|
||||||
}
|
}
|
||||||
if isStructElement {
|
if isStructElement {
|
||||||
vs = make([][]any, 0, len(val))
|
vs = make([][]any, 0, len(val))
|
||||||
|
indexes := make([]int, 0)
|
||||||
for i, v := range val {
|
for i, v := range val {
|
||||||
rv := reflect.Indirect(reflect.ValueOf(v))
|
rv := reflect.Indirect(reflect.ValueOf(v))
|
||||||
if rv.Kind() == reflect.Struct {
|
if rv.Kind() == reflect.Struct {
|
||||||
|
@ -198,13 +200,16 @@ func serializeArray(val []any) (buf []byte, err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
indexes = append(indexes, j)
|
||||||
row = append(row, columnName)
|
row = append(row, columnName)
|
||||||
}
|
}
|
||||||
vs = append(vs, row)
|
vs = append(vs, row)
|
||||||
}
|
}
|
||||||
row := make([]any, 0, rv.Type().NumField())
|
row := make([]any, 0, rv.Type().NumField())
|
||||||
for j := 0; j < rv.Type().NumField(); j++ {
|
for j := 0; j < rv.Type().NumField(); j++ {
|
||||||
row = append(row, rv.Field(j).Interface())
|
if arrays.Exists(j, indexes) {
|
||||||
|
row = append(row, rv.Field(j).Interface())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vs = append(vs, row)
|
vs = append(vs, row)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue