title: Node.js Buffer from hex and readUInt16BE in Golang
body: <p>I have a code like this in nodejs:</p>
  
  <pre><code>// Create Buffer from hex representation
  b = new Buffer('002400050200000000320000000003847209cd4450ff94ad8c0000000002c581000001d3', 'hex')
  
  // Read with offset 0
  b.readUInt16BE(0) // -&gt; Out: 36
  </code></pre>
  
  <p>It reads a string which is an hex representation of data. When first two bytes are read readUInt16BE, an int (36) is obtained. That is the expected behavior.</p>
  
  <p>I need to replicate this behavior using Go, but I have some troubles.</p>
  
  <p>1) How to create a buffer from an string in hex format?
  2) How to implement a readUInt16BE function in order to obtain (36) when first two bytes are read?</p>
  
  <p>I can create a buffer with 00 24, but I need to use any string.</p>
  
  <pre><code>// Creates buffer [00 24]
  v := make([]byte, 0, 2)
  v = append(v, 0)
  v = append(v, 24)
  fmt.Println(v) // -&gt; out: [0 24]
  </code></pre>
  
  <p>Finally, I am a little confused with function binary.BigEndian.Uint16, which is returning 24 instead 36.</p>
  
  <pre><code>x := binary.BigEndian.Uint16(v)
  fmt.Println(x) // -&gt; out: 24
  </code></pre>
  
  <p>Can you help me to understand this?</p>