File tree 1 file changed +10
-9
lines changed 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -32,36 +32,37 @@ func (*RootCmd) stat() *clibase.Cmd {
32
32
var sr statsRow
33
33
34
34
// Get CPU measurements first.
35
- errCh := make (chan error , 2 )
35
+ hostErr := make (chan error )
36
+ containerErr := make (chan error )
36
37
go func () {
38
+ defer close (hostErr )
37
39
cs , err := st .HostCPU ()
38
40
if err != nil {
39
- errCh <- err
41
+ hostErr <- err
40
42
return
41
43
}
42
44
sr .HostCPU = cs
43
- errCh <- nil
44
45
}()
45
46
go func () {
47
+ defer close (containerErr )
46
48
if ok , _ := clistat .IsContainerized (fs ); ! ok {
47
- errCh <- nil
49
+ // don't error if we're not in a container
50
+ return
48
51
}
49
52
cs , err := st .ContainerCPU ()
50
53
if err != nil {
51
- errCh <- err
54
+ containerErr <- err
52
55
return
53
56
}
54
57
sr .ContainerCPU = cs
55
- errCh <- nil
56
58
}()
57
59
58
- if err1 := <- errCh ; err1 != nil {
60
+ if err := <- hostErr ; err != nil {
59
61
return err
60
62
}
61
- if err2 := <- errCh ; err2 != nil {
63
+ if err := <- containerErr ; err != nil {
62
64
return err
63
65
}
64
- close (errCh )
65
66
66
67
// Host-level stats
67
68
ms , err := st .HostMemory ()
You can’t perform that action at this time.
0 commit comments