Function Signature
aguara.go:97
Description
Scans inline content without writing to disk. This is useful for:- Scanning user-provided content before saving
- Validating AI-generated skills in memory
- Testing rules without creating temporary files
- CI/CD pipelines that work with content streams
filename parameter is a hint for rule target matching (e.g., "skill.md", "config.json") but doesn’t need to exist on disk.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | context.Context | Context for cancellation and timeout |
content | string | Content to scan |
filename | string | Filename hint for rule target matching (defaults to "skill.md" if empty) |
opts | ...Option | Functional options (see Options) |
Return Values
| Type | Description |
|---|---|
*ScanResult | Scan results containing findings and metadata |
error | Non-nil if rule compilation fails |
Examples
Basic Usage
Validate AI-Generated Content
Scan JSON Configuration
Scan with Custom Rules
HTTP Handler Example
Testing Rules
Pre-commit Hook Example
Filename Hint
Thefilename parameter helps rules match their target file patterns:
- Rules with
targets: ["*.md"]only match when filename ends with.md - Rules with
targets: ["*.json"]only match.jsonfiles - Rules with no
targetsfield match all filenames - Default is
"skill.md"if filename is empty
Differences from Scan()
| Feature | Scan() | ScanContent() |
|---|---|---|
| Input | File/directory path | String content |
| Disk I/O | Reads from disk | No disk I/O |
| File discovery | Walks directory tree | Single content string |
.aguaraignore | Respected | Not applicable |
| Concurrency | Worker pool | Single target |
| FilePath in results | Actual path | Filename hint |
Performance Notes
- No disk I/O overhead
- No directory walking
- Single-threaded (only one content string)
- Ideal for small to medium content (< 10 MB)
- For large content, consider writing to temp file and using
Scan()
Related
- Scan() - Scan files and directories on disk
- Options - All available functional options
- ScanResult - Result type definition
