Golang Skills Training
Sofiane Imadali, Ayoub Bousselmi
Session 1: generalities and methodology
16/04/2019 Golang Skills 1
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
Goals
16/04/2019 Golang Skills 3
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
General introduction
16/04/2019 Golang Skills 5
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;
Origins and evolution
16/04/2019 Golang Skills 7
Go: TIOBE’s Programming Language of 2016
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.
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
16/04/2019 Golang Skills 10
When you
propose to
develop
in Go…
Journey
from
Python to
Go
16/04/2019 Golang Skills 11
Comparing
programming
languages is like
comparing
sport cars…
Journey from Python to Go
16/04/2019 Golang Skills 12
Python Go
#1 Paradigm
Object oriented
Imperative
Functional
Procedural
Reflective
Procedural
Functional
Concurrent
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
Journey from Python to Go
16/04/2019 Golang Skills 14
Python Go
#3 Type system
Dynamically typed Statically typed
Journey from Python to Go
16/04/2019 Golang Skills 15
Python Go
#4 Syntax
Indentation { opening and closing }
braces
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
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)
16/04/2019 Golang Skills 18
When you
have
choose…
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*
A first code dive:
the Prometheus case
16/04/2019 Golang Skills 20
Methodology
16/04/2019 Golang Skills 21
16/04/2019 Golang Skills 22
Project
Training
Methodology
16/04/2019 Golang Skills 23
Methodology
It’s about finding the balance between training, a project,
and not being bored or lost
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
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 (?)
 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
Thanks
sofiane.imadali@orange.com
ayoub.bousselmi@orange.com
16/04/2019 Golang Skills 27

Golang skills session1: introduction

  • 1.
    Golang Skills Training SofianeImadali, Ayoub Bousselmi Session 1: generalities and methodology 16/04/2019 Golang Skills 1
  • 2.
    Agenda  Goals  Generalintroduction  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
  • 3.
  • 4.
    Goals 16/04/2019 Golang Skills4  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
  • 5.
  • 6.
    Origins and evolution 16/04/2019Golang 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;
  • 7.
    Origins and evolution 16/04/2019Golang Skills 7 Go: TIOBE’s Programming Language of 2016
  • 8.
    Main characteristics, Contextand 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, Contextand 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
  • 10.
    16/04/2019 Golang Skills10 When you propose to develop in Go…
  • 11.
    Journey from Python to Go 16/04/2019 GolangSkills 11 Comparing programming languages is like comparing sport cars…
  • 12.
    Journey from Pythonto Go 16/04/2019 Golang Skills 12 Python Go #1 Paradigm Object oriented Imperative Functional Procedural Reflective Procedural Functional Concurrent
  • 13.
    Journey from Pythonto 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 Pythonto Go 16/04/2019 Golang Skills 14 Python Go #3 Type system Dynamically typed Statically typed
  • 15.
    Journey from Pythonto Go 16/04/2019 Golang Skills 15 Python Go #4 Syntax Indentation { opening and closing } braces
  • 16.
    Journey from Pythonto 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 Pythonto Go 16/04/2019 Golang Skills 17 Python Go #6 Dependencies Management pip install requirements.txt go get go mod vendor Others (glide, GoPkg)
  • 18.
    16/04/2019 Golang Skills18 When you have choose…
  • 19.
    Journey from Pythonto 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 codedive: the Prometheus case 16/04/2019 Golang Skills 20
  • 21.
  • 22.
    16/04/2019 Golang Skills22 Project Training Methodology
  • 23.
    16/04/2019 Golang Skills23 Methodology It’s about finding the balance between training, a project, and not being bored or lost
  • 24.
    16/04/2019 Golang Skills24 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 Skills25 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
  • 27.