zlh-agent/internal/provision/devcontainer/go/verify.go

37 lines
714 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package goenv
import (
"fmt"
"os/exec"
"zlh-agent/internal/state"
)
/*
Verify validates that the Go dev container runtime is usable.
Responsibilities:
- Ensure `go` binary is present and executable
- Ensure GOPATH / GOMOD usage wont immediately fail
IMPORTANT:
- No installation here
- No state mutation
- Safe to call multiple times
*/
func Verify(cfg state.Config) error {
// Check go binary
if _, err := exec.LookPath("go"); err != nil {
return fmt.Errorf("go binary not found in PATH")
}
// Optional sanity check: go env should run
cmd := exec.Command("go", "env")
if err := cmd.Run(); err != nil {
return fmt.Errorf("go env failed to execute")
}
return nil
}