Documentation
¶
Overview ¶
Package memguard detects unbounded memory growth patterns in Go programs.
It loads packages with golang.org/x/tools/go/packages, builds the SSA representation, and runs heuristics that flag append/map-grow/string-concat/ goroutine-spawn inside unbounded loops, recursive accumulators, cross-package growth via passed-by-reference collections, and channel-driven growth.
The library entry point is Analyze. The CLI lives at cmd/mem-guard.
Index ¶
Examples ¶
Constants ¶
const ( SeverityInfo = finding.SeverityInfo SeverityWarning = finding.SeverityWarning SeverityError = finding.SeverityError )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Finding ¶
Re-exports so callers can use a single package import.
func Analyze ¶
Analyze loads the given Go package patterns and runs the configured heuristics. Findings are returned sorted (errors first, then file/line).
Example ¶
package main
import (
"fmt"
memguard "github.com/ProfHercules/mem-guard"
)
func main() {
findings, err := memguard.Analyze([]string{"./testdata/bounded"}, memguard.Options{})
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("findings:", len(findings))
}
Output: findings: 0
type Heuristic ¶
type Heuristic = heuristics.Heuristic
Re-exports so callers can use a single package import.
func DefaultHeuristics ¶
func DefaultHeuristics() []Heuristic
DefaultHeuristics returns a fresh slice of the built-in heuristics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analysis loads Go packages, builds the SSA program, constructs the call graph, and pre-computes loop information that mem-guard heuristics consume.
|
Package analysis loads Go packages, builds the SSA program, constructs the call graph, and pre-computes loop information that mem-guard heuristics consume. |
|
cmd
|
|
|
mem-guard
command
Command mem-guard is the CLI for github.com/ProfHercules/mem-guard.
|
Command mem-guard is the CLI for github.com/ProfHercules/mem-guard. |
|
Package finding defines the Finding type produced by mem-guard heuristics along with severity levels and human/JSON printers.
|
Package finding defines the Finding type produced by mem-guard heuristics along with severity levels and human/JSON printers. |
|
Package heuristics implements the built-in mem-guard checks.
|
Package heuristics implements the built-in mem-guard checks. |
|
internal
|
|
|
cli
Package cli implements the mem-guard command-line interface.
|
Package cli implements the mem-guard command-line interface. |