-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.slide
165 lines (89 loc) · 4.08 KB
/
presentation.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
Introduction to Go
Sometimes called golang
22 Jan 2016
Tags: go golang presentation present
Paul Fortin
Hobbyist Gopher
pfortin@urbn.com
http://urbanoutfitters.com
twitter - @gocodecloud
* Who is this guy?
.image ./paul.jpg 200 200
- Programming addict
- C, Java, Python, and *GO*
- docker contributor
- Developer, urbanoutfitters.com
* What will we talk about?
- Why GO?
- The language overview
- A small WebServer in Go (with templates)
- A bare bones API
- The URBN Inventory importer (InventoryProcessor)
* Why GO? (Page 1)
“Go will be the server language of the future.” - Tobias Lütke, Shopify
Here are a few points of interest...
- Async
The Go runtime ensures that any one goroutine isn’t blocking the others. Code is written in a synchronous style while being fully non-blocking. There is no need for callbacks, so there is no “callback hell.”
- Multicore
Go multiplexes goroutines onto OS threads (like Erlang), and stacks grow as needed. Go not only addresses the C10K problem, it blows past it! (C1000K)
* Why GO (Page 2)
- Concurrency
Go channels provide a concurrency primitive comparable to the actors model. With actors we name the endpoints (mailboxes), whereas channels are the conduit. Want to pass a channel over a channel? Go for it!
- Static Binaries
Go applications compile quickly and launch immediately.
* The language overview
This is going to be a very brief tour of the language but if you want a bit more you can take [[https://tour.golang.org/][A Tour of Go]] where you will find a great intro to the language that can be done betwen 2 and 4 hours). If you are still interested there are now several books written on go and also many more tutorials online about a very comprehensive list of subjects that you might want to play with.
- Installation / Path / IDEs
- Variables
- Functions (Multi returns / Named returns)
- Arrays, Slices, Structs and Maps
- Concurrency
- But what about OO?
* The language overview (Installation)
There are 2 common ways to install Go on your computer:
- An installer for your system (Windows, Linux, Mac (Homebrew)), or;
- GVM (Linux / Mac only)
I recommend GVM as it gives you the most flexibility to switch from one version to another easily. The instructions are simple and you can go thru it on your own.
.link https://golang.org/doc/install
.link https://github.com/moovweb/gvm
* The language overview (Path)
- There are 2 very important environment variables that GO uses:
- GOROOT - Where the GO tools are installed on your system (GVM sets this)
- GOPATH - Where GO will download and install libraries
- Some Libraries: [[https://github.com/avelino/awesome-go]]
- Additionally there are 2 more that are important for cross compiling
- GOOS - compiler/linker target OS
- GOARCH - compiler/linker target architecture
example: GOOS=linux GOARCH=386 go build -o hello hello.go
(compiles for the linux/386 architecture)
* The language overview (IDEs)
There is a vast array of choices from Text Editors to an Eclipse plugin for GO. I will be using WebStorm from JetBrains as I have found that it has a lot of nice built-in functions plus I can use all the frontend tools I want with it.
* The language overview (Hello World)
.play hello.go
* The language overview (Variables)
.play vars.go
* The language overview (Functions - 1)
.play functions_1.go
* The language overview (Functions - 2)
.play functions_2.go
* The language overview (Arrays)
.play arrays.go
* The language overview (Slices)
.play slices.go
* The language overview (Structs)
.play structs.go
* The language overview (Maps)
.play maps.go
* The language overview (Concurrency)
.play concurrency.go
* The language overview (Channels)
.play channels.go
* The language overview (But What about OO)
.play WhatAboutOO.go
* Lets write a full blow webserver in Go in 5 to 10 mins
* Let's write a barebones Profile API
* The InventoryProcessor
* Interesting Links
- http://go-talks.appspot.com/github.com/pfortin-urbn/cop_golang/slides/presentation.slide (This presentation)
- https://play.golang.org/
- https://github.com/SimonWaldherr/golang-examples