vet
supports path exclusions for scenarios where a directory is the scan target but certain path patterns within the directory should be excluded from the scan. This feature is available only for the scan
command and helps optimize scan performance and focus on relevant code.
Basic Usage
Exclude a single path pattern during directory scanning:Multiple Exclusions
Specify multiple path patterns for exclusion:The exclusion pattern matches any path, directory, or file. Internally, it uses Go’s regexp.MatchString function.
Common Exclusion Patterns
Documentation and Build Artifacts
Test Files and Directories
Version Control and Dependencies
Development Tools
Advanced Pattern Examples
File Extension Exclusions
Environment-Specific Exclusions
Complex Pattern Matching
Use Cases
Performance Optimization
Skip large directories that don’t contain relevant package manifests
Test Environment Exclusion
Focus on production dependencies by excluding test files
Build Artifact Filtering
Avoid scanning generated files and build outputs
Monorepo Management
Selectively scan specific parts of large monorepos