1. Golang Skills Training
Sofiane Imadali, Ayoub Bousselmi
Session 1: generalities and methodology
16/04/2019 Golang Skills 1
2. Agenda
Goals
General introduction
Origins and evolution
Main characteristics, Context and Why a new language
Journey from Python to Go (with code snippets)
A first code dive: the Prometheus case
Methodology
Define steps for training (see ToC of tour & Trello)
Long-term project proposal
Tools (tour, github/gitlab (?), wekan …)
16/04/2019 Golang Skills 2
4. Goals
16/04/2019 Golang Skills 4
Understand the basics of the language and be
autonomous to read, modify and create go code
Dive into a long term collaborative project to
develop something meaningful in go
Start creating and integrating Prometheus
exporters in go
6. Origins and evolution
16/04/2019 Golang Skills 6
First appeared
November 10, 2009; 9 years ago
Designed by
Robert Griesemer: known for his work at the Java HotSpot Virtual
Machine
Rob Pike: member of the Unix team at Bell Labs, worked at the Plan 9
and Inferno operating systems and the Limbo programming language
Ken Thompson: (member of the Unix team at Bell Labs, one of the
fathers of C, Unix and Plan 9 operating systems, co-developed UTF-8
with Rob Pike
Stable release
1.12.4 / April 11th, 2019;
8. Main characteristics, Context and Why a new language
16/04/2019 Golang Skills 8
• Go is a language designed from the ground up, as a ‘C for the 21st
century’.
• C-family: C++, Java and C#
• Concurrency mechanism: inspired by Tony Hoare’s CSP (Communicating
Sequential Processes) theory as used by the Erlang language.
• Completely open-source language, distributed with a BSD license, so it can
be used by everybody even for commercial purposes without a fee
• Resemblance with the C-syntax, more concise and clean.
• It also has characteristics of a dynamic language, so Python and Ruby
programmers feel more comfortable with it.
9. Main characteristics, Context and Why a new language
16/04/2019 Golang Skills 9
• C/C++ did not evolve with the computing landscape: so there is a definite
need for a new systems language, appropriate for needs of our computing
era
• In contrast to computing power, software development is not considerably
faster or more successful (considering the number of failed projects) and
applications still grow in size, so a new low-level language, but equipped with
higher concepts, is needed
• Before Go a developer had to choose between fast execution but slow and
not efficient building (like C++), efficient compilation (but not so fast
execution, like .NET or Java), or ease of programming (but slower execution,
like the dynamic languages): Go is an attempt to combine all three wishes:
efficient and thus fast compilation, fast execution, ease of programming
12. Journey from Python to Go
16/04/2019 Golang Skills 12
Python Go
#1 Paradigm
Object oriented
Imperative
Functional
Procedural
Reflective
Procedural
Functional
Concurrent
13. Journey from Python to Go
16/04/2019 Golang Skills 13
Python Go
#2 Execution
Interpreted
(compiled to bytecode)
Garbage collected
Compiled
(statically linked,
dynamically linked)
Garbage collected
14. Journey from Python to Go
16/04/2019 Golang Skills 14
Python Go
#3 Type system
Dynamically typed Statically typed
15. Journey from Python to Go
16/04/2019 Golang Skills 15
Python Go
#4 Syntax
Indentation { opening and closing }
braces
16. Journey from Python to Go
16/04/2019 Golang Skills 16
Python Go
#5 Concurrency
Take time to implement
Extra effort to use all
the available processing
power
simple
built-in
17. Journey from Python to Go
16/04/2019 Golang Skills 17
Python Go
#6 Dependencies Management
pip install
requirements.txt
go get
go mod
vendor
Others (glide, GoPkg)
19. Journey from Python to Go
16/04/2019 Golang Skills 19
Python Ruby Node.js C/C++ Java Go
Semicolons N N Y Y Y N*
Curly braces N N* Y Y Y Y
Static types N N N Y Y Y
Concurrency -
simplicity
N N Y N N Y
Concurrency –
multi-core
N N N Y Y Y
Compiled N N N Y Y Y
OO: classes,
inheritance, etc.
Y Y Y Y Y N*
20. A first code dive:
the Prometheus case
16/04/2019 Golang Skills 20
23. 16/04/2019 Golang Skills 23
Methodology
It’s about finding the balance between training, a project,
and not being bored or lost
24. 16/04/2019 Golang Skills 24
Training
Generalities (today)
Environment
Installation, IDE, Books, and more
The language
Basics
Methods, Interfaces
Concurrency
Idiomatic go and common errors
Production ready code
Project structure
Unitests, Code coverage, and CI/CD
Versioning your code
25. 16/04/2019 Golang Skills 25
Project
Definition (today)
Scrum
Tasks and goals
Tools to use
Contributions in parallel with the training
Code review and releases
Proposal: a basic Prometheus exporter
Using a metrics generator/collector library
Export them to Prometheus
Make a CLI for the tool
Make a dashboard or API (?)
26. Source code
Project, code, and review
Tour and playground
For the training, learning, and testing
Project tasks
Scrum-like, collaboration
16/04/2019 Golang Skills 26
Tools
Github + Travis
Gitlab + Gitlab-CI
Wekan
Trello