-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
359 lines (325 loc) · 10.9 KB
/
index.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Introduction to Go Modules</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/monokai.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
<style>
.code {
background-color: black;
color: gray;
border-radius: 10px;
padding: 4px;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>
Introduction to Go Modules
</h2>
</section>
<section>
<h2>
What is a Go Module?
</h2>
<br>
<p>
collection of Go packages, <br>
stored in a file tree, <br>
with a <span class="code">go.mod</span> file at its root
</p>
</section>
<section>
<h2>
But first...
</h2>
<br>
<p>
How did we got here?
</p>
</section>
<section>
<section>
<h2>
In the beginning...
</h2>
<br>
<p>
All our dependencies should live under <span class="code">$GOPATH</span>
</p>
<br>
<p>
Install them with <span class="code">go
get</span>
</p>
</section>
<section>
<h2>
But what about versioning?
</h2>
<br>
<p>
Everytime we build our application, the latest version of our dependencies would be installed.
</p>
</section>
<section>
<span>
<p> What if someone introduced a breaking change...</p>
<span class="fragment">
<p> ... or decides to delete their repo?</p>
<br><br><br>
<a style="font-size: 20px;" href="https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/">How one
developer just broke Node,
Babel and thousands of projects in 11 lines of JavaScript </a>
</span>
</span>
</section>
</section>
<section>
<section>
<h2>Enter Go 1.5</h2>
</section>
<section>
<h3>
Go 1.5 introduced the experimental <span class="code">vendor</span> feature
</h3>
<br>
<p>This means that whenever we run the <span class="code">go</span> command it would look for our
dependencies under <span class="code">./vendor</span>
</p>
</section>
<section>
<p>People started building tools around that</p>
<ul>
<li class="code" style="margin-bottom: 6px">dep</li>
<li class="code" style="margin-bottom: 6px">govendor</li>
<li class="code" style="margin-bottom: 6px">glide</li>
<li class="code" style="margin-bottom: 6px">godep</li>
<li class="code" style="margin-bottom: 6px">gvt</li>
<li class="code" style="margin-bottom: 6px">govend</li>
</ul>
</section>
<section>
<h4>
All of them operated on the same principle
</h4>
<br>
<p class="fragment"> Describe your dependencies and their version in a manifest file </p>
<p class="fragment"> Run a simple command to download them into the <span class="code">vendor</span> folder
</p>
<br>
<h4 class="fragment"> Familiar? </h4>
</section>
<section>
<h4>
Most of these tools are now deprecated and recommend using go modules
</h4>
<div>
<span style="display: flex; justify-content: center;">
<span style="margin: 20px; font-weight: bold;">govendor</span>
<img src="govendor.png" alt="" height="75px">
</span>
<span style="display: flex; justify-content: center;">
<span style="margin: 20px; font-weight: bold;"> glide </span>
<img src="glide.png" alt="" height="75px">
</span>
<span style="display: flex; justify-content: space-around;">
<img src="godep.png" alt="" height="75px">
<img src="gvt.png" alt="" height="75px">
</span>
</div>
</section>
</section>
<section>
<section>
<h3>
So what exactly are go modules?
</h3>
</section>
<section>
<h3>
As of Go 1.11 modules are Go's new dependency management system
</h3>
</section>
<section>
<h3>
The <span class="code">go.mod</span> file
</h3>
<br>
<p style="font-weight: bold;"> Describes the dependencies and their versions</p>
<br>
<section data-markdown>
<script type="text/template">
```go
module github.com/asankov/gira
go 1.13
require (
github.com/sirupsen/logrus v1.4.2
github.com/docker/docker v1.4.2-0.20190511020111-3998dffb806f
github.com/google/uuid v1.1.1
)
```
</script>
</section>
</section>
<section>
<h3>Managing dependencies</h3>
<br>
Managed by the <span class="code">go mod</span> command
<ul style="font-size: 20px; margin: 10px 0;">
<li style="margin-top: 10px;"> <span class="code">go mod download</span> - download modules to local cache
(<span class="code">$GOPATH/pkg/mod</span>)
</li>
<li style="margin-top: 10px;"> <span class="code">go mod tidy</span> - add missing and remove unused modules
</li>
<li style="margin-top: 10px;"> <span class="code">go mod vendor</span> - make vendored copy of dependencies
</li>
</ul>
<br><br>
All <span class="code">go</span> commands are module aware and all of them interact with the <span
class="code">go.mod</span> file
</section>
<section>
<h3>
Dependency version can be:
</h3>
<p>
<ul>
<li> git tag (preferrably) </li>
<li> git commit hash</li>
</ul>
</p>
<br>
<section data-markdown>
<script type="text/template">
```go
module github.com/asankov/gira
go 1.13
require (
// here v.1.4.2 is just a git tag
github.com/sirupsen/logrus v1.4.2
// either this module has no tags,
// or the develop explicitly asked for this commit hash
github.com/docker/docker v1.4.2-0.20190511020111-3998dffb806f
)
```
</script>
</section>
</section>
<section>
<h3>
Easier migration from one major version to another smoother
</h3>
<br>
<p>
Developers are adviced to publish different modules for their different major version
</p>
<br>
<p> This is easy, because Go modules allows to have modules in a sub-directory of other modules</p>
</section>
<section>
<h3> Central repository trust</h3>
<br>
<p>
Along with <span class="code">go.mod</span> we also have <span class="code">go.sum</span> file.
This contains the checksums of all our dependencies
</p>
<br>
<p>
Therefore, if we try to download a source and the repository is compromised we will know the downloaded
version does not match the expected one
</p>
</section>
<section>
<h3> But what about new dependencies?</h3>
<br>
<p>
The Go team released <a href="https://sum.golang.org/"> a public registry</a> , which will contain the
checksums of all the version of
all the public modules available
</p>
<br>
<img src="gosum.png" alt="">
</section>
<section>
<h3>GOPROXY</h3>
<br>
<p>
Anothing thing which was introduces was <span class="code">$GOPROXY</span>.
If this environment variable is set, the modules will be downloaded from there
</p>
<br>
<p>
The Go team already released the <a href="https://proxy.golang.org/">offical Golang proxy </a>
</p>
</section>
</section>
</section>
<section>
<h2>
Go Modules
</h2>
<br>
<ul>
<li> Go's new official dependency management system </li>
<li> describe your dependencies and their versions in one place </li>
<li> manage them in a seamless way </li>
<li> migrate smoothly between major version </li>
<li> trustless repositories </li>
<li> faster and centralized dependency management </li>
</ul>
</section>
<section>
<div>
<h1>
THANK YOU!
</h1>
<br><br><br>
<div style="display: flex; justify-content: space-between; font-size: 30px;">
<span>
<a href="https://asankov.org/go-modules">asankov.org/go-modules</a>
</span>
<span>
<div>
Anton Sankov,
</div>
Member of Technical Staff at VMware Carbon Black Inc.
</span>
</div>
</div>
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
hash: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true }
]
});
</script>
</body>
</html>