title: How to convert an int64 to int in Go?
body: <p>In Go, what is the best strategy for converting <code>int64</code> to <code>int</code>? I am having difficulty comparing the two</p>
  
  <pre><code>package main 
  
  import (
      "math"
      "strings"
      "strconv"
  )
  
  type largestPrimeFactor struct {
      N      int
      Result int
  }
  
  func main() {
      base := largestPrimeFactor{N:13195}
      max := math.Sqrt(float64(base.N))
  
      maxStr := strconv.FormatFloat(max, 'E', 'G', 64)
      maxShift := strings.Split(maxStr, ".")[0]
      maxInt, err := strconv.ParseInt(maxShift, 10, 64)
  
      if (err != nil) {
          panic(err)
      }
  </code></pre>
  
  <p>on this next line</p>
  
  <pre><code>    for a := 2; a &lt; maxInt; a++ {
          if isPrime(a) {
              if base.N % a == 0 {
                  base.Result = a
              }
          }
      }
  
      println(base)
  }
  
  func isPrime(n int) bool {
      flag := false
  
      max := math.Sqrt(float64(n))
  
      maxStr := strconv.FormatFloat(max, 'E', 'G', 64)
      maxShift := strings.Split(maxStr, ".")[0]
      maxInt, err := strconv.ParseInt(maxShift, 10, 64)
  
      if (err != nil) {
          panic(err)
      }
  
      for a := 2; a &lt; maxInt; a++ {
          if (n % a == 0) {
              flag := true
          }
      }
      return flag
  }
  </code></pre>