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