Skip to main content
vet supports path exclusions when scanning a directory: use the --exclude flag to skip path patterns within the target. Path exclusions are available only for the scan command.

Basic Usage

Exclude a single path pattern during directory scanning:
vet scan -D /path/to/target --exclude 'docs/*'

Multiple Exclusions

Specify multiple path patterns for exclusion:
vet scan -D /path/to/target \
    --exclude 'docs/*' \
    --exclude 'sub/dir/path/*' \
    --exclude '*.test.js'
Exclusion patterns use glob matching (the doublestar library), not regular expressions. Use * to match within a single path segment and ** to match across directories.

Common Exclusion Patterns

Documentation and Build Artifacts

vet scan -D . \
    --exclude 'docs/*' \
    --exclude 'build/*' \
    --exclude 'dist/*' \
    --exclude 'target/*' \
    --exclude '*.generated.*'

Test Files and Directories

vet scan -D . \
    --exclude 'test/*' \
    --exclude 'tests/*' \
    --exclude '*_test.go' \
    --exclude '*.test.js' \
    --exclude 'spec/*'

Version Control and Dependencies

vet scan -D . \
    --exclude '.git/*' \
    --exclude 'node_modules/*' \
    --exclude 'vendor/*' \
    --exclude '.venv/*' \
    --exclude '__pycache__/*'

Development Tools

vet scan -D . \
    --exclude '.idea/*' \
    --exclude '.vscode/*' \
    --exclude '*.log' \
    --exclude 'tmp/*' \
    --exclude 'temp/*'

Advanced Pattern Examples

File Extension Exclusions

# Exclude specific file types
vet scan -D . \
    --exclude '**/*.md' \
    --exclude '**/*.txt' \
    --exclude '**/*.png' \
    --exclude '**/*.jpg'

Environment-Specific Exclusions

# Development environment
vet scan -D . \
    --exclude 'dev-tools/**' \
    --exclude 'local-config/**' \
    --exclude '**/*.dev.*'

# Production build
vet scan -D . \
    --exclude 'test/*' \
    --exclude 'examples/*' \
    --exclude 'dev-dependencies/*'

Complex Pattern Matching

# Exclude multiple similar patterns
vet scan -D . \
    --exclude '**/test/**' \
    --exclude '**/tests/**' \
    --exclude '**/spec/**' \
    --exclude '**/mocks/**'

Makefile Integration

# Makefile with different scan targets
.PHONY: scan-prod scan-dev scan-all

scan-prod:
	vet scan -D . \
		--exclude 'test/*' \
		--exclude 'dev-tools/*' \
		--exclude 'docs/*' \
		--report-json production-scan.json

scan-dev:
	vet scan -D . \
		--exclude 'node_modules/*' \
		--exclude '.git/*' \
		--report-json development-scan.json

scan-all:
	vet scan -D . \
		--exclude '.git/*' \
		--report-json complete-scan.json