Go: go.mod — module directive */
| 323 | |
| 324 | /* Go: go.mod — module directive */ |
| 325 | static void parse_go_mod(const char *source, int source_len, const char *rel_path, |
| 326 | cbm_pkg_entries_t *entries) { |
| 327 | const char *end = source + source_len; |
| 328 | const char *val = find_line_value(source, source_len, "module "); |
| 329 | if (!val) { |
| 330 | return; |
| 331 | } |
| 332 | /* Extract module path (rest of line, trimmed) */ |
| 333 | while (val < end && (*val == ' ' || *val == '\t')) { |
| 334 | val++; |
| 335 | } |
| 336 | const char *start = val; |
| 337 | while (val < end && *val != '\n' && *val != '\r' && *val != ' ') { |
| 338 | val++; |
| 339 | } |
| 340 | if (val <= start) { |
| 341 | return; |
| 342 | } |
| 343 | char *module_path = cbm_strndup(start, (size_t)(val - start)); |
| 344 | char *dir = path_dirname(rel_path); |
| 345 | |
| 346 | /* The module path maps to the directory containing go.mod. |
| 347 | * For "." dir, use empty string. */ |
| 348 | pkg_entries_push(entries, module_path, strdup(dir)); |
| 349 | free(dir); |
| 350 | } |
| 351 | |
| 352 | /* Extract "name" value from a TOML section. Scans from section_start until |
| 353 | * the next [...] header or EOF. Returns heap string or NULL. */ |
no test coverage detected