title: Reading Binary Data in () golang
body: <p>I need to read a specific binary data format (<a href="https://www.usna.edu/Users/oceano/pguth/md_help/html/BT_file_format.htm" rel="nofollow noreferrer">https://www.usna.edu/Users/oceano/pguth/md_help/html/BT_file_format.htm</a>). Go seems to be able to do so quite nicely:</p>
  
  <pre class="lang-golang prettyprint-override"><code>// ...
  
      f, _ := os.Open(filename)
      var data struct {
          Indicator         [10]byte
          Columns           [4]byte
          Rows              [4]byte
          DataSize          [4]byte
          UTMFlag           [2]byte
          UTMZone           [2]byte
          LeftExtend        [4]byte
          RightExtend       [4]byte
          BottomExtend      [4]byte
          TopExtend         [4]byte
          FloatingPointFlag [2]byte
      }
      _ = binary.Read(f, binary.LittleEndian, &amp;data)
  // ...
  </code></pre>
  
  <p>That seems to work since <code>spew.dump(data.Indicator)</code> for example return the correct data. What I do not understand is how to cast fixed slices like <code>[2]byte</code> to an integer I can actually work with. Any suggestions?</p>