-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgo.go
56 lines (43 loc) · 828 Bytes
/
go.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 1. Example ----------------------------------
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
// 2. Tests ----------------------------------
// Values
fmt.Println("go" + "lang")
fmt.Println("1+1 =", 1+1)
fmt.Println("7.0/3.0 =", 7.0/3.0)
fmt.Println(true && false)
fmt.Println(true || false)
fmt.Println(!true)
// Variables
var a string = "initial"
var b, c int = 1, 2
var d = true
var e int
f := "short"
// Constants
const n = 500000000
const d = 3e20 / n
// For
for j := 7; j <= 9; j++ {
fmt.Println(j)
}
// If/Else
if 7%2 == 0 {
fmt.Println("7 is even")
} else {
fmt.Println("7 is odd")
}
// Array
b := [5]int{1, 2, 3, 4, 5}
fmt.Println("dcl:", b)
// Function
func main() {
res := plus(1, 2)
fmt.Println("1+2 =", res)
res = plusPlus(1, 2, 3)
fmt.Println("1+2+3 =", res)
}