(content: &str)
| 578 | LazyLock::new(|| Regex::new(r"(?m)^func\s+(\([^)]*\)\s+)?(\w+)").expect("Go regex")); |
| 579 | |
| 580 | fn extract_go(content: &str) -> Vec<SymbolMatch> { |
| 581 | let mut rows = Vec::new(); |
| 582 | for caps in RE_GO.captures_iter(content) { |
| 583 | let full_match = caps.get(0).unwrap(); |
| 584 | let line_start = line_number_at(content, full_match.start()); |
| 585 | let signature = line_text(content, line_start).trim().to_string(); |
| 586 | let name = caps.get(2).map(|m| m.as_str()).unwrap_or(""); |
| 587 | let visibility = if name.chars().next().map(|c| c.is_uppercase()).unwrap_or(false) { |
| 588 | "export" |
| 589 | } else { |
| 590 | "" |
| 591 | }; |
| 592 | rows.push(SymbolMatch { |
| 593 | name: name.to_string(), |
| 594 | kind: "function".to_string(), |
| 595 | line_start, |
| 596 | line_end: line_start, |
| 597 | signature, |
| 598 | visibility: visibility.to_string(), |
| 599 | }); |
| 600 | } |
| 601 | rows |
| 602 | } |
no test coverage detected