65 lines
1009 B
Go
65 lines
1009 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math/cmplx"
|
|
)
|
|
|
|
var c, java, python bool
|
|
var n, m int = 1, 2
|
|
var (
|
|
ToBe bool = false
|
|
MaxInt uint64 = 1<<64 - 1
|
|
z complex128 = cmplx.Sqrt(-5 + 12i)
|
|
)
|
|
|
|
func add(x, y int) int {
|
|
return x + y
|
|
}
|
|
|
|
func swap (x, y string) (string, string) {
|
|
return y, x
|
|
}
|
|
|
|
func split(sum int) (x, y int) {
|
|
x = sum * 4 / 9
|
|
y = sum - x
|
|
return
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println(add(42,13))
|
|
x := [3]int{2,1,1}
|
|
fmt.Println(x)
|
|
|
|
a, b := swap("hello", "go")
|
|
fmt.Println(a, b)
|
|
|
|
fmt.Println(split(17))
|
|
|
|
var i int
|
|
fmt.Println(i, c, python, java)
|
|
|
|
c, java, python := true, true, "no!"
|
|
k := 3
|
|
fmt.Println(k, n, m, c, python, java)
|
|
|
|
fmt.Printf("Type: %T Value: %v\n", ToBe, ToBe)
|
|
fmt.Printf("Type: %T Value: %v\n", MaxInt, MaxInt)
|
|
fmt.Printf("Type: %T Value: %v\n", z, z)
|
|
|
|
g := 42
|
|
f := float64(g)
|
|
u := uint(f)
|
|
fmt.Println(g, f, u)
|
|
|
|
const Pi = 3.14
|
|
const World = "世界"
|
|
const Truth = true
|
|
|
|
fmt.Println("Hello", World)
|
|
fmt.Println("Happy", Pi, "Day")
|
|
fmt.Println("Go rules?", Truth)
|
|
}
|
|
|