mirror of
https://github.com/taigrr/systemctl.git
synced 2026-03-09 00:14:38 -07:00
check stderr before reporting back error 1
This commit is contained in:
10
README.md
10
README.md
@@ -40,17 +40,17 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/taigrr/systemctl/v1"
|
||||
"github.com/taigrr/systemctl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Equivalent to `systemctl enable dhcpd` with a 10 second timeout
|
||||
err := systemctl.Enable(ctx, "dhcpd")
|
||||
userMode := false
|
||||
// Equivalent to `systemctl enable nginx` with a 10 second timeout
|
||||
err := systemctl.Enable(ctx, "nginx", userMode)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to enable unit %s: %v", "dhcpd", err)
|
||||
log.Fatalf("unable to enable unit %s: %v", "nginx", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user