Ensure defer does not exit program
This commit is contained in:
parent
b052f8d897
commit
5d07060a78
8
main.go
8
main.go
@ -60,12 +60,6 @@ var (
|
|||||||
nextSleepTime time.Time
|
nextSleepTime time.Time
|
||||||
)
|
)
|
||||||
|
|
||||||
func Must(err error) {
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Check if running as root
|
// Check if running as root
|
||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
@ -79,7 +73,7 @@ func main() {
|
|||||||
nvmlAvailable = false
|
nvmlAvailable = false
|
||||||
} else {
|
} else {
|
||||||
nvmlAvailable = true
|
nvmlAvailable = true
|
||||||
defer Must(nvml.Shutdown())
|
defer nvml.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up signal handling
|
// Set up signal handling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user