Skip to content

Commit

Permalink
fix: fix linux code
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Sep 14, 2023
1 parent ee4ac7d commit 7fec818
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/uptime/uptime_linux.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package uptime

import "os"
import (
"fmt"
"math"
"os"
"time"
)

var (
rawUptimeImpl UptimeSource = &LinuxUptime{}
Expand All @@ -14,7 +19,7 @@ type UptimeSource interface {
func Uptime() (time.Duration, error) {
seconds, err := rawUptimeImpl.RawUptime()
if err != nil {
return time.Time{}, fmt.Errorf("could not read raw uptime: %w", err)
return time.Duration(0), fmt.Errorf("could not read raw uptime: %w", err)
}

return time.Second * time.Duration(seconds), nil
Expand All @@ -28,5 +33,5 @@ func (p *LinuxUptime) RawUptime() (float64, error) {
if err != nil {
return math.MaxFloat64, err
}
return parseLinuxUptime(uptime)
return parseLinuxUptime(string(uptime))
}

0 comments on commit 7fec818

Please sign in to comment.