pkg.re/essentialkaos/ek.10@v12.41.0+incompatible/system/info_uptime_darwin.go (about)

     1  package system
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2022 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"golang.org/x/sys/unix"
    12  )
    13  
    14  // ////////////////////////////////////////////////////////////////////////////////// //
    15  
    16  // GetUptime returns uptime in seconds from 1/1/1970
    17  func GetUptime() (uint64, error) {
    18  	tv, err := unix.SysctlTimeval("kern.boottime")
    19  
    20  	if err != nil {
    21  		return 0, err
    22  	}
    23  
    24  	return uint64(tv.Sec), nil
    25  }