Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 11:37
Show Gist options
  • Save percybolmer/d1f03d7662e2ba2b01aa81e1e4ff8244 to your computer and use it in GitHub Desktop.
Save percybolmer/d1f03d7662e2ba2b01aa81e1e4ff8244 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type Human struct {
Name string
}
// This is our method receiver, the type Human receives the Hello method
func (h Human) Hello() string {
return fmt.Sprintf("Hello, %s!", h.Name)
}
func main() {
h := Human{
Name: "Bob",
}
// Since human has received the method Hello, we can call it
fmt.Println(h.Hello())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment