Skip to content

Commit e08741f

Browse files
committed
Fix sudo warning
1 parent 6c44842 commit e08741f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

main.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ func setupUI() {
170170

171171
func setupGrid() {
172172
grid = ui.NewGrid()
173-
174-
// Define the rows and columns
175173
grid.Set(
176174
ui.NewRow(1.0/2, // This row now takes half the height of the grid
177175
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))),
@@ -211,8 +209,6 @@ func switchGridLayout() {
211209
ui.NewCol(2.0/6, NetworkInfo),
212210
),
213211
)
214-
215-
// Set the new grid's dimensions to match the terminal size
216212
termWidth, termHeight := ui.TerminalDimensions()
217213
newGrid.SetRect(0, 0, termWidth, termHeight)
218214
grid = newGrid
@@ -237,7 +233,6 @@ func switchGridLayout() {
237233
ui.NewCol(1.0, memoryGauge),
238234
),
239235
)
240-
// Set the new grid's dimensions to match the terminal size
241236
termWidth, termHeight := ui.TerminalDimensions()
242237
newGrid.SetRect(0, 0, termWidth, termHeight)
243238
grid = newGrid
@@ -250,16 +245,12 @@ func StderrToLogfile(logfile *os.File) {
250245
syscall.Dup2(int(logfile.Fd()), 2)
251246
}
252247

253-
func main() {
248+
// goasitop main function
254249

255-
if os.Geteuid() != 0 && len(os.Args) > 1 && os.Args[1] != "--test" {
256-
fmt.Println("Welcome to goasitop! Please try again and run goasitop with sudo privileges!")
257-
fmt.Println("Usage: sudo goasitop")
258-
os.Exit(1)
259-
}
250+
func main() {
260251

261252
// get version from git
262-
version := "v0.1.0"
253+
version := "v0.1.1"
263254
if len(os.Args) > 1 && os.Args[1] == "--version" {
264255
fmt.Println("goasitop version:", version)
265256
os.Exit(0)
@@ -271,6 +262,12 @@ func main() {
271262
os.Exit(0)
272263
}
273264

265+
if os.Geteuid() != 0 {
266+
fmt.Println("Welcome to goasitop! Please try again and run goasitop with sudo privileges!")
267+
fmt.Println("Usage: sudo goasitop")
268+
os.Exit(1)
269+
}
270+
274271
logfile, err := setupLogfile()
275272
if err != nil {
276273
stderrLogger.Fatalf("failed to setup log file: %v", err)

0 commit comments

Comments
 (0)