syncable_cli/analyzer/tool_management/installers/
go.rs

1use crate::analyzer::tool_management::ToolDetector;
2use crate::error::{AnalysisError, IaCGeneratorError, Result};
3use super::common::InstallationUtils;
4use std::collections::HashMap;
5use log::{info, warn};
6
7/// Install govulncheck for Go vulnerability scanning
8pub fn install_govulncheck(
9    tool_detector: &mut ToolDetector,
10    installed_tools: &mut HashMap<String, bool>,
11) -> Result<()> {
12    if tool_detector.detect_tool("govulncheck").available {
13        return Ok(());
14    }
15    
16    info!("🔧 Installing govulncheck for Go vulnerability scanning...");
17    
18    let success = InstallationUtils::execute_command("go", &[
19        "install", 
20        "golang.org/x/vuln/cmd/govulncheck@latest"
21    ])?;
22    
23    if success {
24        info!("✅ govulncheck installed successfully");
25        installed_tools.insert("govulncheck".to_string(), true);
26        tool_detector.clear_cache();
27        info!("💡 Note: Make sure ~/go/bin is in your PATH to use govulncheck");
28    } else {
29        warn!("❌ Failed to install govulncheck");
30        warn!("📦 Please install Go from https://golang.org/ first");
31    }
32    
33    Ok(())
34}