Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 4e68f80

Browse files
author
huong
committed
check exist in -c option
1 parent 879cf26 commit 4e68f80

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ func getColumn(code string, fields map[string]*kintone.FieldInfo) *Column {
124124
return &column
125125
}
126126

127+
func containtString(arr []string, str string) bool {
128+
for _, a := range arr {
129+
if a == str {
130+
return true
131+
}
132+
}
133+
return false
134+
}
135+
127136
// set Cell information from fieldinfo
128137
// function replace getColumn so getColumn is invalid name
129138
func getCell(code string, fields map[string]*kintone.FieldInfo) *Cell {
@@ -270,7 +279,7 @@ func main() {
270279
} else {
271280
fields := config.Fields
272281
isAppendIdCustome := false
273-
if len(config.Fields) > 0 {
282+
if len(config.Fields) > 0 && !containtString(config.Fields, "$id") {
274283
fields = append(fields, "$id")
275284
isAppendIdCustome = true
276285
}
@@ -304,10 +313,9 @@ func main() {
304313
} else {
305314
fields := config.Fields
306315
isAppendIdCustome := false
307-
if len(config.Fields) > 0 {
316+
if len(config.Fields) > 0 && !containtString(config.Fields, "$id") {
308317
fields = append(fields, "$id")
309318
isAppendIdCustome = true
310-
311319
}
312320
err = exportRecordsBySeekMethod(app, writer, fields, isAppendIdCustome)
313321
}

0 commit comments

Comments
 (0)