go-sleep/cmd/sleep/main.go

26 lines
399 B
Go
Raw Permalink Normal View History

2021-12-15 12:00:46 +00:00
// SPDX-FileCopyrightText: 2021 Eric Neidhardt
// SPDX-License-Identifier: MIT
2020-01-20 17:45:19 +00:00
package main
2021-12-15 12:00:46 +00:00
import (
"fmt"
"os"
"strconv"
"time"
)
2020-01-21 06:33:45 +00:00
2020-01-20 17:45:19 +00:00
func main() {
2020-01-21 06:33:45 +00:00
sleep := 1
if len(os.Args) > 1 {
var err error
sleep, err = strconv.Atoi(os.Args[1])
if err != nil {
fmt.Printf("Given %s is not a valid sleep time\n", os.Args[1])
os.Exit(1)
}
}
time.Sleep(time.Duration(sleep) * time.Second)
2020-01-20 17:45:19 +00:00
}