Skip to content

Instantly share code, notes, and snippets.

@giwa
Created January 27, 2015 09:54
Show Gist options
  • Save giwa/98ce201764bd677bcb69 to your computer and use it in GitHub Desktop.
Save giwa/98ce201764bd677bcb69 to your computer and use it in GitHub Desktop.
package main
import "fmt"
// 2つのintを取りその合計を返す関数です。
func plus(a int, b int) int {
// Goは明示的なreturnが必要です。
// 例えば、最後の値を自動的に返すことはありません。
return a + b
}
func main() {
// 関数を呼ぶのは予測通り、name(args)で呼ぶことができます。
res := plus(1, 2)
fmt.Println("1+2 =", res)
}
$ go run functions.go
1+2 = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment