From e669582aceef67f9e36b20796f1ee3d139e991af Mon Sep 17 00:00:00 2001 From: "Paul Buetow (europa)" Date: Mon, 1 Jun 2015 23:00:08 +0100 Subject: Add root check --- gotop/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- cgit v1.2.3