New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in arm64 docker #10
Comments
Chatgpt search: The error message indicates that there was an attempt to access an element of an empty slice. This can happen when the slice has no elements and an attempt is made to access an element at a specific index. In the provided code snippet, the error occurs in the cpuTimes() method of the util struct. Specifically, it occurs when the cpu.Times() function returns an error and the times slice is empty. This can happen if there is an issue with obtaining the CPU times statistics. To fix the issue, you can add a check to ensure that the times slice has at least one element before attempting to access it. For example: times, err := cpu.Times(false)
if err != nil {
return nil, err
}
if len(times) == 0 {
return nil, errors.New("cpu.Times() returned an empty slice")
}
s := &cpuTimesStat{
total: cpuTotal(×[0]),
system: times[0].System,
user: times[0].User,
idle: times[0].Idle,
}
s.other = s.total - s.system - s.user - s.idle
return s, nil |
Thanks for the report. Would you share what your host system is and which |
Thanks, |
Thank you so much your code helped solve my problem !!! |
Hey @drunkod |
`panic: runtime error: index out of range [0] with length 0
goroutine 20 [running]:
github.com/datarhei/core/v16/psutil.(*util).cpuTimes(0x40000a8edc?)
/dist/core/psutil/psutil.go:288 +0x184
github.com/datarhei/core/v16/psutil.(*util).collect(0x40000a8f70?)
/dist/core/psutil/psutil.go:247 +0x28
github.com/datarhei/core/v16/psutil.(*util).tick(0x400013c000, {0xd799c0, 0x40000a4910}, 0x0?)
/dist/core/psutil/psutil.go:236 +0xe8
created by github.com/datarhei/core/v16/psutil.(*util).Start.func1
/dist/core/psutil/psutil.go:133 +0xd8`
The text was updated successfully, but these errors were encountered: