27 lines
450 B
Go
27 lines
450 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
)
|
|
|
|
func add(x int, y int) int {
|
|
return x + y
|
|
}
|
|
|
|
func add2(x, y int) int {
|
|
return x + y
|
|
}
|
|
|
|
func swap(x, y string) (string, string) {
|
|
return y, x
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println("You know Pi =", math.Pi)
|
|
fmt.Println("And You know 1+2 =", add(1, 2))
|
|
fmt.Println("And You know 1+2 =", add2(1, 2), "Using syntax sugar")
|
|
a, b := swap("hello", "world")
|
|
fmt.Println("And You know swap('hello', 'world') =", a, b)
|
|
}
|