mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-18 21:57:27 +08:00
refactor: use slices.Contains to simplify code (#16680)
### Summary There is a [new function](https://pkg.go.dev/slices@go1.21.0#Contains) added in the go1.21 standard library, which can make the code more concise and easy to read. Signed-off-by: weifanglab <weifanglab@outlook.com>
This commit is contained in:
@@ -2012,18 +2012,11 @@ func convertSelectFields(output []string, isSkillIndex ...bool) []string {
|
||||
|
||||
// Add id and empty count if needed
|
||||
// For skill index, use skill_id instead of id
|
||||
hasID := false
|
||||
idField := "id"
|
||||
if skillIndex {
|
||||
idField = "skill_id"
|
||||
}
|
||||
for _, f := range result {
|
||||
if f == idField {
|
||||
hasID = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasID {
|
||||
if !slices.Contains(result, idField) {
|
||||
result = append([]string{idField}, result...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user