# Nos débuts en Go...
#### Démo équipe Monitoring du 07/02/2022
---
# Objectif
- boostraper l'équipe Monitoring sur le langage GO
---
# Installer Go
Deux façons d'installer Go :
- https://go.dev/doc/install
- PPA [ppa:longsleep/golang-backports](https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports)
----
## Installer avec le PPA
```
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
```
```
sudo apt install golang golang-1.17
```
---
# Hello World
- Compiler Hello World
- Exécuter Hello World
- Configurer `$GOPATH` et `$PATH` (dans le bashrc/zshrc)
----
## Compiler et exécuter Hello World
Nous suivons la doc https://go.dev/doc/tutorial/getting-started
Commandes :
- `go build .` et `go build -o main main.go`
- `go run .`
- `go install .`
- `go fmt .` et `go fmt main.go`
----
## GOPATH et PATH
Lorsqu'un programme est compilé, il est installé dans l'arborescence `$GOPATH`
Le répertoire des binaires est `$GOPATH/bin`
```
$ cat .bashrc # ou .zshrc
export GOPATH=$(go env GOPATH)
export PATH=${GOPATH}/bin:${PATH}
```
---
# Le tour de Go
Il s'agit de la description interactive du langage GO
- https://go.dev/tour/
- https://pkg.go.dev/
- https://pkg.go.dev/std
<style type="text/css">
p {
font-size: smaller;
}
.reveal ul ul li {
font-size: smaller;
}
.reveal section {
text-align: left;
}
}
.reveal h3 {
color: orange;
text-align: center;
border-bottom: 1px solid orange;
}
.reveal h1 {
color: orange;
text-align: center;
border-bottom: 1px solid orange;
margin-bottom: 0.4em;
}
.reveal code {
color: aquamarine;
font-size: smaller;
}
</style>
{"type":"slide","slideOptions":{"transition":"slide","center":true}}