title: Convert int to a single byte in Go
body: <p><a href="https://github.com/tarm/serial/blob/master/serial.go#L103" rel="nofollow">https://github.com/tarm/serial/blob/master/serial.go#L103</a></p>
  
  <pre><code>type StopBits byte
  type Parity byte
  
  type Config struct {
      Name        string
      Baud        int
      ReadTimeout time.Duration
      Size byte
      Parity Parity
      StopBits StopBits
  }
  </code></pre>
  
  <p>I am trying to flag the command line and fill in the config struct but i can't figure out how to go from int or string to a single byte?</p>
  
  <p>example size 7</p>
  
  <p>Tried</p>
  
  <pre><code>mysize := "7"
  mysize[0]
  </code></pre>
  
  <p>but then tarm/serial tells me invalid input error in the serial.Config </p>
  
  <pre><code>i, err := strconv.Atoi("7")
  </code></pre>
  
  <p>compiler complains that i can't do <code>i.(byte)</code></p>
  
  <p>The only way I can make it work is to hardcode <code>size: 7</code> in the config struct.</p>