Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Created March 21, 2014 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskoz/9694990 to your computer and use it in GitHub Desktop.
Save vaskoz/9694990 to your computer and use it in GitHub Desktop.
Go Method Types
package main
import "fmt"
type Point struct {}
func (p *Point) Scale() {
fmt.Println("method")
}
func Scale(p *Point) {
fmt.Println("function")
}
func main() {
p := Point{}
ptrA := p.Scale
ptrB := Scale
fmt.Printf("Type of method Scale is: %T\n", ptrA)
fmt.Printf("Type of function Scale is: %T\n", ptrB)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment