title: Golang retrieve application uptime
body: <p>I'm trying to retrieve the current uptime of my <code>Go</code> application.</p>
  
  <p>I've seen there's a package <a href="https://golang.org/pkg/syscall/" rel="noreferrer"><code>syscall</code></a> which provides a <a href="https://golang.org/pkg/syscall/#Sysinfo_t" rel="noreferrer"><code>type Sysinfo_t</code></a> and a method <a href="https://golang.org/pkg/syscall/#Sysinfo" rel="noreferrer"><code>Sysinfo(*Sysinfo_t)</code></a> which apparently allows you to retrieve the Uptime (since it's a field of the <code>Sysinfo_t</code> struct)</p>
  
  <p>What I've done so far is:</p>
  
  <pre><code>sysi := &amp;syscall.Sysinfo_t{}
  
  if err := syscall.Sysinfo(sysi); err != nil {
      return http.StatusInternalServerError, nil
  }
  </code></pre>
  
  <p>The problem is that at compile time I get this:</p>
  
  <pre><code>/path/to/file/res_system.go:43: undefined: syscall.Sysinfo_t
  /path/to/file/res_system.go:45: undefined: syscall.Sysinfo
  </code></pre>
  
  <p>I've searched a bit and apparently that method and type are available only on Linux and I need the application to run both on Linux and OsX (which I'm currently using).</p>
  
  <p>Is there a cross-compatible way to retrieve the application uptime?</p>
  
  <p><strong>NOTE</strong>: I'd rather not use any third party libraries (unless they're absolutely necessary)</p>