import { wrapMinimal } from '../utils.js';
export function parseComGo(codigo) {
    const functions = Array.from(codigo.matchAll(/\bfunc\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
    const types = Array.from(codigo.matchAll(/\btype\s+([A-Za-z0-9_]+)\s/gs)).map(m => m[1]);
    const imports = Array.from(codigo.matchAll(/"([^"]+)"/g)).map(m => m[1]);
    const interfaces = Array.from(codigo.matchAll(/\btype\s+([A-Za-z0-9_]+)\s+interface/g)).map(m => m[1]);
    const structs = Array.from(codigo.matchAll(/\btype\s+([A-Za-z0-9_]+)\s+struct/g)).map(m => m[1]);
    const methods = Array.from(codigo.matchAll(/func\s+\(([A-Za-z0-9_]+)\s+\*?([A-Za-z0-9_]+)\)\s+([A-Za-z0-9_]+)/g)).map(m => ({
        receiver: m[1],
        type: m[2],
        name: m[3]
    }));
    const vars = Array.from(codigo.matchAll(/\bvar\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
    const consts = Array.from(codigo.matchAll(/\bconst\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
    const structFields = Array.from(codigo.matchAll(/type\s+(\w+)\s+struct\s*\{([^}]*)\}/gs)).map(m => {
        const fields = m[2].trim().split('\n').map(line => {
            const trimmed = line.trim();
            if (!trimmed || trimmed.startsWith('//'))
                return null;
            const parts = trimmed.split(/\s+/);
            return parts.length >= 2 ? { name: parts[0], type: parts.slice(1).join(' ') } : null;
        }).filter(Boolean);
        return { structName: m[1], fields };
    });
    const packages = Array.from(codigo.matchAll(/^package\s+([A-Za-z0-9_]+)/gm)).map(m => m[1]);
    return wrapMinimal('go', {
        functions,
        types,
        imports,
        interfaces,
        structs,
        methods,
        vars,
        consts,
        structFields,
        packages
    });
}
//# sourceMappingURL=go.js.map