mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 23:26:45 +08:00
fix panic on no containers
This commit is contained in:
11
grid.go
11
grid.go
@@ -16,13 +16,16 @@ type Grid struct {
|
||||
|
||||
func NewGrid() *Grid {
|
||||
cmap := NewContainerMap()
|
||||
containers := cmap.All()
|
||||
return &Grid{
|
||||
cursorID: containers[0].id,
|
||||
g := &Grid{
|
||||
cmap: cmap,
|
||||
containers: containers,
|
||||
containers: cmap.All(),
|
||||
header: widgets.NewCTopHeader(),
|
||||
}
|
||||
// set initial cursor position
|
||||
if len(g.containers) > 0 {
|
||||
g.cursorID = g.containers[0].id
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
// Return current cursor index
|
||||
|
||||
Reference in New Issue
Block a user