🗑️ Uninstall
Uninstalls Composer from the system.
When to Use
Use this when you need to remove the Composer executable and its .phar file. It first locates the current composer path, then deletes that path and the composer.phar in the same directory. 🧹
Signature
go
func (i *Installer) Uninstall() errorParameters
| Parameter | Type | Description |
|---|---|---|
| None | — | Behavior is determined by Config.UseSudo for whether sudo is used to delete |
Return Value
error:nilon success; returns a wrapped error when composer is not found; returns the corresponding error on deletion failure. ⚠️
Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/installer"
)
func main() {
i := installer.DefaultInstaller()
if err := i.Uninstall(); err != nil {
log.Fatalf("uninstall failed: %v", err)
}
fmt.Println("Composer uninstalled")
}Advanced
- If the file is in a directory that requires elevated permissions, set
Config.UseSudototrue; otherwise the deletion will fail due to insufficient permissions. 🔒 - You can use
IsInstalledbeforehand to confirm presence and avoid needless errors. ✅ - Under the hood it calls the package-level function
UninstallComposer, which also cleans upcomposer.phar. 🧩