class

Analyzer::Go::GoZero

Inherits Analyzer::Go::GoEngine < Analyzer::Go::GoTestPath < Analyzer < FileHelper < Reference < Object

Constants

API_ROUTE_LINE = /^\s*(get|post|put|delete|patch|head|options)\s+([^\s\(]+)(?:\s*\(\s*(\w+)\s*\))?/
API_TYPE = /^\s*(?:type\s+)?([A-Za-z_]\w*)\s*\{([^{}]*)\}/m

A .api type body: DetailReq { ... } inside type (...), or type SearchReq {...}.

IMPORT_MARKER = "github.com/zeromicro/go-zero"
IMPORT_MARKER_RE = Regex.union(IMPORT_MARKER)

One precompiled matcher instead of a String#includes? scan per .go file: includes? runs Rabin-Karp over the whole buffer and the marker is absent in the overwhelming majority of files in a polyglot repo, so every one of them pays the full scan. See Analyzer#content_matches?.

PARAM_ACCESSOR_PATTERNS = ["Query", "PostForm", "GetHeader", "PathParam", "FormValue"].to_h do |pattern| {pattern, /#{Regex.escape(pattern)}\(\s*"([^"]+)"/} end

Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile). The accessor set is fixed, so precompile the per-accessor matchers once at load time.

PARSE_CALL = /\bhttpx\.Parse(\w*)\(\s*\w+\s*,\s*&\s*([A-Za-z_]\w*)\s*\)/

httpx.Parse(r, &req) and its ParseJsonBody / ParseForm / ParsePath / ParseHeaders siblings.

PARSE_TAGS = {"" => ["path", "form", "header", "json"] of ::String, "Path" => ["path"] of ::String, "Form" => ["form"] of ::String, "Headers" => ["header"] of ::String, "JsonBody" => ["json"] of ::String}

The tag kinds each httpx.Parse* variant fills; Parse fills them all.

Class methods

tech_name
Source

Instance methods

analyze
Source
get_param(line : String, pattern : String) : Param

Type the param by the actual accessor name. The previous version always returned "query" regardless of accessor, so r.PathParam("id") and r.GetHeader("X-Token") surfaced as query params — a mis-classification that broke downstream consumers (auth taggers, OpenAPI export) that key off param_type.

Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source