fix command line exclude column

This commit is contained in:
fancl 2024-04-29 15:17:23 +08:00
parent bef2e35e41
commit 7fff2f8a1c
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"git.nspix.com/golang/kos/util/arrays"
"git.nspix.com/golang/kos/util/pool"
"github.com/mattn/go-runewidth"
"reflect"
@ -184,6 +185,7 @@ func serializeArray(val []any) (buf []byte, err error) {
}
if isStructElement {
vs = make([][]any, 0, len(val))
indexes := make([]int, 0)
for i, v := range val {
rv := reflect.Indirect(reflect.ValueOf(v))
if rv.Kind() == reflect.Struct {
@ -198,13 +200,16 @@ func serializeArray(val []any) (buf []byte, err error) {
continue
}
}
indexes = append(indexes, j)
row = append(row, columnName)
}
vs = append(vs, row)
}
row := make([]any, 0, rv.Type().NumField())
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)
} else {