-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgolang-intro.slide
105 lines (65 loc) · 1.81 KB
/
golang-intro.slide
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
golang
let's go
Muhammad Falak R Wani
@vimfrw
falakreyaz@gmail.com
* Agenda
- A light hearted intro to *golang*
- I already know python why should I switch
- Some cool stuff
- Who is the creator and who uses it.
* A tribute to the demo gods
.play -edit src/hello.go
* Why should I swtich
- I already know python so why a new language
- Cross compiling is as easy as native compiling
- You Dont write complex makefiles, or have to bend you head for complex build systems
- The tooling is awsome.
* Who created it
The creators of UNIX
- Ken Thompson (Turing award winner)
- Rob Pike
- Russ Cox
Legend has it, Ken and Rob were waiting for a project to compile, they thougth of redesigning a language
that was modern enough and could tackle the scale at google.
* Structure of a Typical go program
- package
- imports
- globla vars
- funcs
- func *main*
* Is go Object oriented.
- Although you can use it as an object oriented langugage, it is not.
- It feels like one.
* Let me try to sell go
- Cross compiling
- Pretty loaded standard library (battries included)
- All round development, Benchmarking and Testing bundled in the languge
- Relatively leaner build times
- Extensive tooling (more on that latter)
* Some more
- Looks and feels like Python
- Statically Typed
- Compiled
- Simple
* What are use cases of go
- Its typically used a systems langugage
- People use for web dev too
- Docker has been written in go.
* Lets start coding
* Values, Variables & Constants
.play -edit src/val_var.go
: The short variable declaration only works inside functions
* Loops
There is just one looping construct *for*
.play -edit src/loops.go
* Conditionals
.play -edit src/if-else.go
* Switch
.play -edit src/switch.go
* Arrays
.play -edit src/array.go
* Slices
.play -edit src/slice.go
* 2D Slice
.play -edit src/slice2.go