darktile
darktile copied to clipboard
'undefined: getUptime' error when building in Mac
Hi I get this error when building in Mac
./scripts/build.sh
# github.com/liamg/darktile/internal/app/darktile/hinters
internal/app/darktile/hinters/hint_dmesg_timestamp.go:54:54: undefined: getUptime
make: *** [build] Error 1
It is MacOS Ventura 13.1
Thanks Jasmeer
Create file ./internal/app/darktile/hinters/uptime_darwin.go with contents:
//go:build cgo && (darwin)
package hinters
/*
#include <stdlib.h>
#include <time.h>
#ifdef __APPLE__
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
time_t getuptime() {
struct timeval boottime;
size_t size = sizeof(boottime);
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0) {
return -1;
}
return time(NULL) - boottime.tv_sec;
}
#else
#include <sys/timespec.h>
time_t getuptime() {
struct timespec tp;
clock_gettime(CLOCK_UPTIME, &tp);
return tp.tv_sec;
}
#endif
*/
import "C"
func getUptime() int64 {
t := C.getuptime()
if t < 0 {
return 0
}
return int64(t)
}
And if you get error "vendor/git.wow.st/gmp/clip/ns/pasteboard.go:194:127: invalid operation: (func() _Ctype_BOOL {…}()) != 0 (mismatched types _Ctype_BOOL and untyped int)"
edit file vendor/git.wow.st/gmp/clip/ns/pasteboard.go replace line
ret := (C.NSPasteboard_inst_SetString(o.Ptr(), string.Ptr())) != 0
with:
ret := bool(C.NSPasteboard_inst_SetString(o.Ptr(), string.Ptr()))