Skip to content

🩺 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

ParameterTypeDescription
NoneThis method takes no parameters

Return value

  • string: Raw output text of composer diagnose, including multiple check results
  • error: 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/error structure, use DiagnoseStructured
  • To attach options, use DiagnoseWithOptions (see diagnosis.go)
  • For a one-shot comprehensive health check, use HealthCheck

Released under the MIT License