title: how to work with hexstrings and bit shifting in golang
body: <p>I have a hexademial string that I constructed from arduino sensor <code>&quot;5FEE012503591FC70CC8&quot;</code></p>
  <p>This value contains an array of with specific data placed at specific locations of the hex string. Using javascript I can convert the hexstring to a buffer then apply bit shifting operations to extract data, for example battery status like so</p>
  <pre><code>  const bytes = new Buffer.from(&quot;5FEE012503591FC70CC8&quot;, &quot;hex&quot;);
    const battery = (bytes[8] &lt;&lt; 8) | bytes[9];
    console.log(battery)
  </code></pre>
  <p>My attemp works but I feel its not optimal like the js way I have shown above</p>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;strconv&quot;
  )
  
  func main() {
      hex := &quot;5FEE012503591FC70CC8&quot;
      bat, err := strconv.ParseInt(hex[16:20],16,64)
      if err != nil {
          panic(err)
      }
      fmt.Println(&quot;Battry: &quot;,bat)
  }
  </code></pre>
  <p>I would really appreciate if someone could show me how to work with buffers or equivalent to the js solution but in go. FYI the battery information is in the last 4 characters in the hex string</p>