title: Golang : interface to swap two numbers
body: <p>I want to swap two numbers using interface but the interface concept is so confusing to me. </p>
  
  <p><a href="http://play.golang.org/p/qhwyxMRj-c" rel="noreferrer">http://play.golang.org/p/qhwyxMRj-c</a></p>
  
  <p>This is the code and playground.  How do I use interface and swap two input numbers? Do I need to define two structures?</p>
  
  <pre><code>type num struct {
      value interface{}
  }
  
  type numbers struct {
      b *num
      c *num
  }
  
  func (a *num) SwapNum(var1, var2 interface{}) {
      var a num
  
      temp := var1
      var1 = var2
      var2 = temp
  }
  
  func main() {
      a := 1
      b := 2
      c := 3.5
      d := 5.5
  
      SwapNum(a, b)
      fmt.Println(a, b) // 2 1
      SwapNum(c, d)
      fmt.Println(c, d) // 5.5 3.5
  }
  </code></pre>