daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Aug 15th, 2018 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.   //Declare a pointer of type Human
  9.   peter := new(Human)
  10.   //The compile will dereference the pointer to make the call
  11.   peter.sayHello()
  12. }
  13.  
  14. //custom defined interface
  15. type Person interface {
  16.  sayHello()
  17. }
  18.  
  19. //custom defined type
  20. type Human struct {}
  21.  
  22. //Human type implements Person interface
  23. func (p *Human) sayHello() { fmt.Println("Hello") }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top