title: Golang: How do I convert command line arguments to integers?
body: <p>I want to make a script that does an insertion sort on the arguments provided by the user, like this:</p>
  
  <pre><code>    $ insertionSort 1 2 110 39
  </code></pre>
  
  <p>I expect it to return:</p>
  
  <pre><code>    [1 2 39 110]
  </code></pre>
  
  <p>But it returns:</p>
  
  <pre><code>    [1 110 2 39]
  </code></pre>
  
  <p>I think it's because the elements in the os.Args array are strings. So, my question is how do I convert the elements of the os.Args array into integers? Here's my code:</p>
  
  <pre><code>    package main
  
      import (
          "fmt"
           "os"
           "reflect"
           "strconv"
      )
  
      func main() {
          A := os.Args[1:]
  
          for i := 0; i &lt;= len(A); i++ {
            strconv.Atoi(A[i])
            fmt.Println(reflect.TypeOf(A[i]))
          }
  
           for j := 1; j &lt; len(A); j++ {
               key := A[j]
               i := j - 1
               for i &gt;= 0 &amp;&amp; A[i] &gt; key {
                 A[i+1] = A[i]
                 i = i - 1
                 A[i+1] = key
               }
            }
          fmt.Println(A)
      }
  </code></pre>
  
  <p>As a heads up, when I substitute</p>
  
  <pre><code>     strconv.Atoi(A[i])
  </code></pre>
  
  <p>For</p>
  
  <pre><code>     A[i] = strconv.Atoi(A[i])
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>    ./insertionSort.go:14: multiple-value strconv.Atoi() in single-value context
  </code></pre>
  
  <p>Thank you for your time!</p>