• Declare Method
  • Method and Function can be the same name
  • Method and Field can not have the same name
  • Can declare another method name in the same file for different type
  • To modify instance value directly, use pointer to declare Method
  • Pointer type can't be declared as method receiver.
  • When a receiver is declared as a pointer, client code should use & to call method.
    But Go will convert it implicitly
  • Can not call method in *Point because no address if temp value. Ex. Point{}.add(2)//compile error
  • Ways to declare and use receiver



What to read next

Previous / Next
Previous: Go - Functions - 6 (panic, recover, stackTrace) Next: Convert CQL query result file hex to ascii
More like this
Subscribe via RSS: Macro · Tech

Tags:

Updated: