🩺 Diagnose
Diagnoses the system to identify common Composer errors (runs composer diagnose).
When to use
When Composer has network, certificate, cache, permission, or other tricky issues, first run diagnose for a systematic check to quickly locate the source of the problem.
Signature
go
func (c *Composer) Diagnose() (string, error)Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return value
string: Raw output text ofcomposer diagnose, including multiple check resultserror: Returned when the command fails
Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatal(err)
}
output, err := comp.Diagnose()
if err != nil {
log.Fatalf("diagnose failed: %v", err)
}
fmt.Println(output)
}Advanced
- To parse each check into an
ok/warning/errorstructure, use DiagnoseStructured - To attach options, use
DiagnoseWithOptions(see diagnosis.go) - For a one-shot comprehensive health check, use HealthCheck