title: Read uint8 from []byte without creating a bytes.Buffer
body: <p>How to read a <code>unit8</code> from <code>[]byte</code> without creating a <code>bytes.Buffer</code>. The value has been written to the buffer like this,</p>
  
  <pre class="lang-golang prettyprint-override"><code>buf := new(bytes.Buffer)
  binary.Write(buf, binary.BigEndian, uint32(1))
  binary.Write(buf, binary.BigEndian, uint8(1))
  b := buf.Bytes()
  </code></pre>
  
  <p>While decoding, it can easily be done for <code>uint32</code>, like the following...</p>
  
  <pre class="lang-golang prettyprint-override"><code>len := binary.BigEndian.Uint32(b[:4])
  </code></pre>
  
  <p>But for the <code>uint8</code>, the only way to retrieve the value that I could come up with, is to create a buffer and then read the first byte,</p>
  
  <pre class="lang-golang prettyprint-override"><code>buf := new(bytes.Buffer)
  _, err := buf.Write(b[4:5])
  // error handling ...
  id = buf.ReadByte()
  </code></pre>
  
  <p>It seems like there's no method in the <code>encoding/binary</code> pkg for <code>uint8</code> value retrieval. And I guess there's probably some good reason behind it.</p>
  
  <p>Question: Is there any other way to read <code>uint8</code> from that <code>[]byte</code> without creating a <code>Buffer</code>??</p>