package goenv

import (
	"fmt"
	"os"
	"os/exec"

	"zlh-agent/internal/state"
)

const goBin = "/opt/zlh/runtimes/go/bin/go"

func Verify(cfg state.Config) error {
	if _, err := os.Stat(goBin); err != nil {
		return fmt.Errorf("go binary missing at %s", goBin)
	}

	if err := exec.Command(goBin, "version").Run(); err != nil {
		return fmt.Errorf("go runtime not executable: %w", err)
	}

	return nil
}
