title: How to take command argument in Go?
body: <p>I just start to learn Go, and I wrote a prime test program using the <code>ProbablyPrime</code> library. </p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "math/big"
      "math"
      "os"
      "strconv"
  )
  
  func prime_test(n int64, certainty int)(bool,float64){
      var probobility float64
      i := big.NewInt(n)
      isPrime := i.ProbablyPrime(certainty)
      probobility = 1 - 1/math.Pow(4,10)
      return isPrime, probobility
  }
  
  func why_not_prime(n int64)(int64){
      var i int64 
      for  i=2 ; i&lt;n/2; i++ {
          if n%i == 0 {return i}
      }
      return i
  }
  
  
  func main() {
      var n int64
      var certainty int
      var isPrime bool
      var probobility float64 
  
      if len(os.Args) &gt; 1 {
      n,_ = strconv.ParseInt(os.Args[1],64,64)
      certainty,_ = strconv.Atoi(os.Args[2])
      }
  
      isPrime, probobility = prime_test(n,certainty)
      if isPrime {
          fmt.Printf("%d is probably %0.8f%% a prime.", n, probobility*100)
      } else {
          var i int64
          i = why_not_prime(n)
          fmt.Printf("%d is a composite because it can be divided by %d", n, i)
      }
  }
  </code></pre>
  
  <p>The code could be successfully compiled. When I run it, it always return <code>0 is a composite because it can be divided by 2</code>.</p>
  
  <p>I guess there's something wrong with the command line argument parsing. How to fix it?</p>