🔒 CanUseSudo
Checks whether the sudo command is available on the current system.
When to Use
Use this when installing/uninstalling requires writing to system directories and you need to decide whether to prefix commands with sudo. ✅
Signature
go
func CanUseSudo() boolParameters
| Parameter | Type | Description |
|---|---|---|
| None | — | Package-level function, takes no parameters |
Return Value
bool:truemeanssudoexists in thePATH;falsemeans it is unavailable.
Example
go
package main
import (
"fmt"
"github.com/scagogogo/composer-skills/pkg/installer"
)
func main() {
if installer.CanUseSudo() {
fmt.Println("sudo is available for privilege escalation")
} else {
fmt.Println("sudo is unavailable; write to user-writable directories")
}
}