Slide 1

Slide 1 text

À la découverte de Go 16 Février 2023

Slide 2

Slide 2 text

Donia Chaiehloudj www.containerdays.io #CDS22 Organisatrice du GDG Sophia-Antipolis Membre WHAT06 Women Techmakers Ambassador @doniacld Software Backend Engineer - 6 ans de Go

Slide 3

Slide 3 text

C’est quoi Go? Un langage de programmation: ● simple ● efficace ● open-source ● sympa ● compilé ● typé http://golang.org Go = Golang Représenté par sa mascotte: un Gopher

Slide 4

Slide 4 text

Un peu d’histoire Go a été désigné par Google pour résoudre des problèmes internes à Google. Google a de gros problèmes.

Slide 5

Slide 5 text

Pourquoi Go ? ● éliminer les ralentissements ● améliorer la productivité ● maintenir/améliorer la capacité d’accepter un grand nombre de requêtes Go was designed by and for people who write—and read and debug and maintain—large software systems. Go's purpose is not research into programming language design. Go's purpose is to make its designers' programming lives better. https://go.dev/talks/2012/splash.slide#8 Go at Google, SPLASH, Tucson, Oct 25, 2012, Rob Pike

Slide 6

Slide 6 text

Que faire avec Go ? source: https://go.dev/blog/survey2022-q2-results ● API/RPC services ● CLI ● Outils de déploiements

Slide 7

Slide 7 text

Go est utilisé par qui ? ● Google ● Microsoft ● Meta ● Dell ● HP ● Intel ● SAP ● IBM ● Walmart ● RedHat source: https://go.dev/blog/survey2022-q2-results

Slide 8

Slide 8 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Commenter avec ‘//’ ou ‘/* */‘

Slide 9

Slide 9 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Nom du package Commenter avec ‘//’

Slide 10

Slide 10 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Nom du package Les imports des dépendances Commenter avec ‘//’

Slide 11

Slide 11 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Nom du package Les imports des dépendances Déclaration d’une fonction: main Commenter avec ‘//’

Slide 12

Slide 12 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Nom du package Les imports des dépendances Déclaration d’une fonction: main Corps de la fonction Commenter avec ‘//’

Slide 13

Slide 13 text

Exemple d’un fichier en Go: main.go // Entrypoint of the program package main import "fmt" func main() { fmt.Println("Hello Le Wagon Nice") } Nom du package Les imports des dépendances Déclaration d’une fonction: main Corps de la fonction Commenter avec ‘//’

Slide 14

Slide 14 text

var delayMinutes int // -8 (signed integer) var wagonNumber uint // 8 (unsigned integer) var temperature float32 // 21.5 (decimal) Number var isPassenger bool // false Bool Types de base var wagon string // “W46” String

Slide 15

Slide 15 text

train := "TGV" Variable avec initialisation Variables var = := var train string = "TGV" Variable avec initialisation courte Plusieurs variables avec initialisation et même type var , = , var train1, train2 string = "TGV1", "TGV2"

Slide 16

Slide 16 text

// string const WagonBar = "Bar" // enumeration const ( debug = iota // 0 info // 1 fatal // 2 error // 3 ) Constantes const = const ( = iota ... )

Slide 17

Slide 17 text

Structures type struct { } Création type Wagon struct { Kind string Number int } wagonBar := Wagon{Kind: "Bar" , Number: 4} // explicit fields wagonBar := Wagon{"Bar", 4} // omit fields // wagonBar.Kind = "Bar" & wagonBar.Number = 4 := {: , : } Déclaration de la variable

Slide 18

Slide 18 text

func register(passenger string, place int) Paramètres Fonctions func getWagonNumber() int Plusieurs valeurs retournées func ( , ) func () func getWagonNumber() (int, error) func () (, ) Une valeur retournée error est un type en Go

Slide 19

Slide 19 text

Outils go build . Compile le code du package et ses dépendances, génère un fichier exécutable go run $PKG Compile le code du package $PKG et ses dépendances & lance le programme go test $PKG Lance les tests du package $PKG go fmt $PKG Résout les problèmes de format du package $PKG source: https://go-talks.appspot.com/github.com/davecheney/canberra-gophers/introduction-to-go.slide#46

Slide 20

Slide 20 text

Demo time https://github.com/doniacld/go-le-wagon

Slide 21

Slide 21 text

Not covered Beaucoup de choses! ● Flow Statements (if, else, if else, for) ● Concurrence (goroutines, channels) ● ...

Slide 22

Slide 22 text

La communauté Go Women Who Go GopherCon Europe London Gophers GoBridge

Slide 23

Slide 23 text

Par où commencer? 1. Go Tour: https://go.dev/tour/ 2. Go Playground: https://go.dev/play/ 3. Documentation officielle: https://pkg.go.dev/std

Slide 24

Slide 24 text

Apprends Go à ton rythme avec des projets de poche 35% avec le code mtplewagon23 http://mng.bz/91Wx @doniacld Donia Chaiehloudj Crée ton propre Gopher https://gopherize.me/ https://hachyderm.io/@doniacld www.doniacld.com donia-chaiehloudj 🚂 https://github.com/doniacld/go-le-wagon

Slide 25

Slide 25 text

Apprends Go à ton rythme avec des projets de poche 35% avec le code mtplewagon23 http://mng.bz/91Wx 🚂 https://tinyurl.com/go-le-wagon 📚 🎁 QUIZZ ❓