use super::{DetectResult, ProjectDef};
use std::path::Path;

use anyhow::Result;

pub const DEF: ProjectDef = ProjectDef {
    name: "go",
    detect: detect,
    build_cmd: &["go", "build", "-o", "app", "."],
    run_cmd: &["./app"],
};

fn detect(dir: &Path) -> Result<DetectResult> {
    let matched = dir.join("go.mod").exists();
    Ok(if matched { DetectResult::matched() } else { DetectResult::no_match() })
}
