-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoNotes
More file actions
111 lines (77 loc) · 1 KB
/
Copy pathgoNotes
File metadata and controls
111 lines (77 loc) · 1 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
1. variables
2. functions
3. if / loops
4. arrays & slices
5. maps
6. structs
7. interfaces
8. goroutines
9. channels
10. networking
= -> assiognment, for already declared varibles
```go
var x int
x = 10
```
=: -> decllare then asssignment, for first time
```go
x = 10
```
```
var x int = 10
```
-> Datatypes at the end of declaration
Functions:
``````````
```go
func add(a int, b int) int {
return a+b
}
func main(){
x := add(2,3)
}
```
If-else:
````````
```go
if age>=10{
fmt.Println("big")
}else {
fmt.Println("small")
}
```
Loops:
``````
for i:=10;i<10;i++ {
}
Arrays:
```````
```go
var nums [3]int
nums[0] = 1;
num := []int{10, 20, 30}
```
Maps:
`````
```go
age := map[string]int{
"Mohit" : 21
}
```
Structs
```````
```go
type User struct {
NAME string
AGE int
}
user := User{
NAME : "mohit",
AGE : 21
}
```
Concurrency - Goroutiens
````````````````````````
go func(){
fmt.Println("This will create lightweight thread")
}