MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_go_mod

Function parse_go_mod

src/pipeline/pass_pkgmap.c:321–346  ·  view source on GitHub ↗

Go: go.mod — module directive */

Source from the content-addressed store, hash-verified

319
320/* Go: go.mod — module directive */
321static 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. */

Callers 1

cbm_pkgmap_try_parseFunction · 0.85

Calls 4

find_line_valueFunction · 0.85
cbm_strndupFunction · 0.85
path_dirnameFunction · 0.85
pkg_entries_pushFunction · 0.85

Tested by

no test coverage detected