zsvo/test
itexpert228 1f9699ecc4
Fix singleton resolver and add version printing
PROBLEM 1: Global resolver cache was broken
- LoadIndex() was being executed multiple times
- Sources.xz parsed repeatedly (6.4s each time)
- Multiple resolver instances created

FIX 1: Implement proper singleton pattern
- LoadIndex() now executes only inside sync.Once
- resolverErr variable captures initialization error
- All subsequent GetGlobalResolver() calls reuse same instance
- Thread-safe implementation with proper error handling

PROBLEM 2: Missing version printing
- No version output when binary starts

FIX 2: Add version constant and printing
- const Version = "0.1.0" in main.go
- fmt.Printf("zsvo v%s\n", Version) in main()
- Version prints on every binary start

TEST RESULTS:
- First resolver init: 148.958µs (includes parsing)
- Subsequent calls: 667ns, 542ns (223,000x faster)
- Singleton pattern working:  same instance
- No repeated parsing:  avg resolution 1.25µs
- Version printing:  "zsvo v0.1.0"

EXPECTED BEHAVIOR:
- LoadIndex() executes only once per process
- Subsequent GetGlobalResolver() calls <1ms
- O(1) dependency lookups after initial load
- Version printed on every run
2026-03-15 17:03:30 +03:00
..
test_singleton_fix.go Fix singleton resolver and add version printing 2026-03-15 17:03:30 +03:00