summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow (europa) <paul@buetow.org>2015-06-01 23:00:08 +0100
committerPaul Buetow (europa) <paul@buetow.org>2015-06-01 23:00:08 +0100
commite669582aceef67f9e36b20796f1ee3d139e991af (patch)
tree3d99db863712c9849a3484537ce7589da292bb6f
parent37e28c93a04dbbba69c85f1b461653d9fbb01591 (diff)
Add root check
-rw-r--r--gotop/main.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/gotop/main.go b/gotop/main.go
index 0af15f3..470d616 100644
--- a/gotop/main.go
+++ b/gotop/main.go
@@ -14,6 +14,7 @@ import (
"log"
"os"
"os/signal"
+ "os/user"
"syscall"
"time"
)
@@ -247,6 +248,16 @@ func main() {
os.Exit(0)
}()
+ user, err := user.Current()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ if user.Username != "root" {
+ fmt.Println("Warning: You are not root, so you will not see everything!")
+ time.Sleep(time.Duration(2) * time.Second)
+ }
+
for {
tChan <- true
time.Sleep(config.interval)