✅ Check
Checks whether composer.json and composer.lock are in sync and whether dependencies meet the requirements (runs composer check).
When to use
Use for consistency validation after installing or updating dependencies, or to assert in CI that the lock file is not outdated.
Signature
go
func (c *Composer) Check() (string, error)Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return value
string: Raw output text ofcomposer checkerror: 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.Check()
if err != nil {
log.Fatalf("check failed: %v", err)
}
fmt.Println(output)
}Advanced
- For structured results (
Valid+ error/warning lists), use CheckStructured - To attach options, use
CheckWithOptions(see diagnosis.go) - To specifically validate the
composer.jsonschema, use theValidatefamily (see validate.go / config.go)