✅ IsInstalled
Quickly determines whether Composer is installed on the system.
When to Use
Use this when you only need a boolean result to decide subsequent flow (for example, checking before installation, or confirming the environment is ready before running a command). It is a simplified wrapper around Detect. 🎯
Signature
go
func (d *Detector) IsInstalled() boolParameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return Value
bool:truemeans a Composer executable was detected;falsemeans not detected.
Example
go
package main
import (
"fmt"
"github.com/scagogogo/composer-skills/pkg/detector"
)
func main() {
d := detector.NewDetector()
if d.IsInstalled() {
fmt.Println("Composer is installed, you may continue")
} else {
fmt.Println("Composer is not installed, please install it first")
}
}Advanced
- Implementation is equivalent to
_, err := d.Detect(); return err == nil; it does not throw an error, making it suitable for direct use in conditionals. 🛠️ - If you also need the path, calling
Detectdirectly is more efficient, avoiding a redundant lookup. 💡 - For detailed information (hit method, etc.), use
DetectVerbose.