Last active
August 29, 2015 14:07
-
-
Save jochasinga/7074b122780558e154d1 to your computer and use it in GitHub Desktop.
Basic method calling before implementing interfaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Man struct { | |
language string | |
// other factors to decide if the girl would like you (for fun) | |
name, nationality, build, eye_color string | |
age, height uint8 | |
// you could be in debt, so we can't rule out negative values | |
income int64 | |
// this is to remind her you are available | |
married bool | |
} | |
func (m Man) Greet() { | |
switch m.language { | |
case "British" : fmt.Println("Good morning, dear") | |
case "American": fmt.Println("Mornin' there") | |
case "Japanese": fmt.Println("Ohayou Gozaimasu") | |
case "Thai" : fmt.Println("Arunsawad Krub") | |
default : fmt.Println("Good morning") | |
} | |
} | |
func main() { | |
jay := new(Man) // just leave other fields to 0 | |
jay.language = "Japanese" | |
jay.Greet() // print "Ohayou Gozaimasu" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment