mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +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 {
|
func NewGrid() *Grid {
|
||||||
cmap := NewContainerMap()
|
cmap := NewContainerMap()
|
||||||
containers := cmap.All()
|
g := &Grid{
|
||||||
return &Grid{
|
|
||||||
cursorID: containers[0].id,
|
|
||||||
cmap: cmap,
|
cmap: cmap,
|
||||||
containers: containers,
|
containers: cmap.All(),
|
||||||
header: widgets.NewCTopHeader(),
|
header: widgets.NewCTopHeader(),
|
||||||
}
|
}
|
||||||
|
// set initial cursor position
|
||||||
|
if len(g.containers) > 0 {
|
||||||
|
g.cursorID = g.containers[0].id
|
||||||
|
}
|
||||||
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return current cursor index
|
// Return current cursor index
|
||||||
|
|||||||
Reference in New Issue
Block a user