diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ab071a..0f4fae9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v2 with: - go-version: '^1.16.6' + go-version: '^1.17' - run: go version - name: Release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c407fa..f280d5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - go-version: [1.16.x] + go-version: [1.17.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: diff --git a/internal/app/darktile/hinters/hint_dmesg_timestamp.go b/internal/app/darktile/hinters/hint_dmesg_timestamp.go index 7c48103..cb6aced 100644 --- a/internal/app/darktile/hinters/hint_dmesg_timestamp.go +++ b/internal/app/darktile/hinters/hint_dmesg_timestamp.go @@ -4,7 +4,6 @@ import ( "regexp" "strconv" "strings" - "syscall" "time" "github.com/liamg/darktile/internal/app/darktile/termutil" @@ -52,7 +51,5 @@ func (h *DmesgTimestampHinter) Click(api HintAPI) error { } func setSysStartTime() { - sysInfo := &syscall.Sysinfo_t{} - _ = syscall.Sysinfo(sysInfo) - sysStart = time.Now().Local().Add(time.Duration(int(sysInfo.Uptime*-1)) * time.Second) + sysStart = time.Now().Local().Add(time.Duration(int(getUptime()*-1)) * time.Second) } diff --git a/internal/app/darktile/hinters/uptime.go b/internal/app/darktile/hinters/uptime.go new file mode 100644 index 0000000..78ba37b --- /dev/null +++ b/internal/app/darktile/hinters/uptime.go @@ -0,0 +1,23 @@ +//go:build cgo && (freebsd || openbsd) + +package hinters + +/* +#include +#include +#include +#include + + +time_t getuptime() { + struct timespec tp; + clock_gettime(CLOCK_UPTIME, &tp); + return tp.tv_sec; +} +*/ +import "C" + +func getUptime() int64 { + time := C.getuptime() + return int64(time) +} diff --git a/internal/app/darktile/hinters/uptime_builtin.go b/internal/app/darktile/hinters/uptime_builtin.go new file mode 100644 index 0000000..484fb4d --- /dev/null +++ b/internal/app/darktile/hinters/uptime_builtin.go @@ -0,0 +1,13 @@ +//go:build cgo && (linux || netbsd) + +package hinters + +import ( + "syscall" +) + +func getUptime() int64 { + sysInfo := &syscall.Sysinfo_t{} + _ = syscall.Sysinfo(sysInfo) + return sysInfo.Uptime +}