🗑️ GlobalRemove
Removes (uninstalls) an installed package from the Composer global environment.
When to use
Use this when a global CLI tool is no longer needed, or when you want to clean up the global environment. Equivalent to running composer global remove <package>.
Signature
go
func (c *Composer) GlobalRemove(packageName string) errorParameters
| Parameter | Type | Description |
|---|---|---|
packageName | string | The name of the package to remove from the global environment, e.g. psy/psysh |
Return value
error: Returns the corresponding error message when an error occurs during execution (e.g. the package is not installed); nil on success.
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.Fatalf("Initialization failed: %v", err)
}
// Remove psysh from the global environment
if err := comp.GlobalRemove("psy/psysh"); err != nil {
log.Fatalf("Removal failed: %v", err)
}
fmt.Println("Removed psy/psysh from the global environment")
}Advanced
- To remove multiple packages at once, use
GlobalRemoveMultiple. - To pass options such as
--no-progressor--no-update, use theGlobalRemoveWithOptionsvariant. - After removal, call
GlobalListto confirm the current global package list. - For the reverse operation (installing), see
GlobalRequire.