title: Go: Type assertions on structs?
body: <pre><code>package main
  
  import "fmt"
  
  type Number int
  
  func (n *Number) IncreaseMe(i int) {
          *n += i
  }
  
  func main() {
          n := Number(10)
  
          n.IncreaseMe(90) // n is now supposed to be 100
  
          fmt.Println(n)
  }
  </code></pre>
  
  <p>When running the code above, it gives me the error message </p>
  
  <blockquote>
    <p>invalid operation: *n += i (mismatched types Number and int)</p>
  </blockquote>
  
  <p>Which is to be expected as it's trying to do a math operation on variables which don't share the same type. </p>
  
  <p>I then tried </p>
  
  <pre><code>*n.(int) += i
  </code></pre>
  
  <p>which tells the compiler not to worry as *n can be safely treated as an integer, which leads me to</p>
  
  <pre><code>invalid type assertion: n.(int) (non-interface type *Number on left)
  </code></pre>
  
  <p>I believe this is happening because type assertions works only with interfaces, not custom types.</p>
  
  <p>So what is the solution for this?</p>