Open mfossen opened 5 years ago
Perhaps you have a 32 bit machine, and golang doesn't have an int64 on that (or at least not in the struct?) I don't know, but if you dig some more, please let us know. Also, you can fix this by adding a
lang/funcs/core/sys/uptime_fact_WHATEVER.go
where WHATEVER is the specific arch.
LMK
Since this issue wasn't solved yet:
I had that exact error while compiling for armhf, which indeed is a 32-bit SoC. Creating a architecture specific uptime_fact_armhf.go file didnt work out since the error was still thrown in the _posix file (so both files were included). In the end I simply casted it to int64 in the return, which is the best solution for both 64 bit and 32 bit architectures (as far as I understood with my very limited golang knowdlege).
The good thing is, I got it to successfully to compile after fixing a few other similiar places that had overflow issues on 32-bit architectures in structs and maps. The bad thing is that 3 of those were within an external dependency, so I can't just do a simple PR here for now.
Anyway, mgmt compiles and works on armhf (armv7)
Versions:
mgmt version (eg:
mgmt --version
):operating system/distribution (eg:
uname -a
):Linux localhost 3.10.18 #1 SMP Sun Mar 3 22:48:34 PST 2019 armv7l GNU/Linux
go version
):go version go1.11.5 linux/arm
Description:
Running
make build
throws an errorlang/funcs/core/sys/uptime_fact_posix.go:32:16: cannot use sysinfo.Uptime (type int32) as type int64 in return argument
Casting it as an
int64
in thereturn
lets it build fine. What I'm confused about is the struct containsUptime
as anint64
in it, so the error is probably related to the weird machine setup I'm using? An older Acer ARM Chromebook with a Debian chroot using crouton.If you know why that's happening, that's great! If not then feel free to close this, I can PR a
return int64(sysinfo.Uptime), nil
if you'd like, even though it should be working as is...FWIW, the error exists with the regular
syscall
import or by switching it out forhttps://godoc.org/golang.org/x/sys/unix
.