plackemacher / system-shutdown

Go package to shut down, reboot, sleep, or hibernate the system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

system-shutdown

CI/CD

system-shutdown provides a cross-platform way to shut down, reboot, sleep, or hibernate operations.

Supported platforms: Linux, Windows, and macOS.

Based on the work from the Rust crate system_shutdown.

Usage

Add this to your go.mod:

require (
    github.com/plackemacher/system-shutdown
)

and then:

package main

import (
    "fmt"
    "github.com/plackemacher/system-shutdown"
    "os"
)

func main() {
    err := system_shutdown.Shutdown()
    if err != nil {
        println("Shutting down, bye!")
    } else {
        fmt.Fprintf(os.Stderr, "Failed to shut down: %v", err)
    }
}

In most of the systems it does not require the user to be root or admin.

Contributions

Pull Requests are welcome! =)

License

system-shutdown is licensed under either of the following, at your option:

About

Go package to shut down, reboot, sleep, or hibernate the system.

License:Apache License 2.0


Languages

Language:Go 100.0%