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

Function parse_go_mod

src/pipeline/pass_pkgmap.c:325–350  ·  view source on GitHub ↗

Go: go.mod — module directive */

Source from the content-addressed store, hash-verified

323
324/* Go: go.mod — module directive */
325static 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. */

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