Skip to content

Instantly share code, notes, and snippets.

@PyYoshi
Created September 16, 2015 08:53
Show Gist options
  • Save PyYoshi/eaaf5907dc81ea052faf to your computer and use it in GitHub Desktop.
Save PyYoshi/eaaf5907dc81ea052faf to your computer and use it in GitHub Desktop.
package main
import "fmt"
func 後藤(i int) {
fmt.Println("Q: 後藤さんは何匹でしょう?")
if i == 1 {
goto STATUS1
} else if i == 2 {
goto STATUS2
} else {
goto OTHER
}
STATUS1:
fmt.Println("A: 後藤さんは1匹")
return
STATUS2:
fmt.Println("A: 後藤さんは2匹")
return
OTHER:
fmt.Printf("A: 後藤さんは%d匹\n", i)
return
}
func main() {
後藤(1)
後藤(2)
後藤(3)
// gotoを利用するなら関数で分けてreturnで止めるやり方がいいと思う
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment