(rowData map[any]string, filler string, cols []string, isCaseSensitive bool, id ...any)
| 607 | } |
| 608 | |
| 609 | func getRowData(rowData map[any]string, filler string, cols []string, isCaseSensitive bool, id ...any) []string { |
| 610 | maxRange := 2000000 |
| 611 | ret := make([]string, 0, len(id)) |
| 612 | dup := make(map[any]struct{}, len(id)) |
| 613 | for i := range id { |
| 614 | isStr := false |
| 615 | switch x := id[i].(type) { |
| 616 | case int: |
| 617 | if x >= maxRange { |
| 618 | continue |
| 619 | } |
| 620 | case string: |
| 621 | if isCaseSensitive { |
| 622 | if x >= "x" { |
| 623 | continue |
| 624 | } |
| 625 | } else { |
| 626 | lc := strings.ToLower(x) |
| 627 | if lc >= "x" { |
| 628 | continue |
| 629 | } |
| 630 | } |
| 631 | isStr = true |
| 632 | default: |
| 633 | panic("Unsupported type") |
| 634 | } |
| 635 | if _, ok := dup[id[i]]; ok { |
| 636 | continue |
| 637 | } |
| 638 | var row string |
| 639 | for j, col := range cols { |
| 640 | if j > 0 { |
| 641 | row += " " |
| 642 | } |
| 643 | switch col { |
| 644 | case "a": |
| 645 | if isStr { |
| 646 | row += id[i].(string) |
| 647 | } else { |
| 648 | row += strconv.Itoa(id[i].(int)) |
| 649 | } |
| 650 | case "b": |
| 651 | row += rowData[id[i]] |
| 652 | case "c": |
| 653 | row += filler |
| 654 | case "space(1)": |
| 655 | row += " " |
| 656 | } |
| 657 | } |
| 658 | ret = append(ret, row) |
| 659 | dup[id[i]] = struct{}{} |
| 660 | } |
| 661 | sort.Strings(ret) |
| 662 | return ret |
| 663 | } |
| 664 | |
| 665 | func getRandCols(seededRand *rand.Rand) ([]string, bool) { |
| 666 | allCols := []string{"a", "b", "c", "space(1)"} |
no test coverage detected