title: Golang compare numbers
body: <p>I have two <code>interface{}</code>s <code>a</code> and <code>b</code> from JSON decoding and user input, let's say: </p>
  
  <pre><code>var a interface{} = ...
  var b interface{} = ...
  </code></pre>
  
  <p>I know they are numbers. They could be any of the following types:</p>
  
  <pre><code>unit
  unit8
  uint16
  uint32
  uint64
  int
  int8
  int16
  int32
  int64
  float
  float32
  float64
  </code></pre>
  
  <p>I wrote some test code as follows. It turned out that when a variable is <code>int</code>, it will fail with <code>int64</code> assertion.</p>
  
  <pre><code>var a interface{} = 1
  v, f := a.(int64)
  fmt.Println(v, f) //0 false
  v1, f1 := a.(int)
  fmt.Println(v1, f1) //1 true
  </code></pre>
  
  <p>So now my question is as follows: in order to compare these two numbers, do I have to test all the permutations of these more than 10 types just in order to get the types of these two <code>interface{}</code> variables? Ideally, I just want to cast them to <code>int64</code> or <code>float64</code>, but if they are <code>int</code> or <code>float</code>, I have no way to find them until exhausted all possible types.</p>