Slide 1

Slide 1 text

GO FOR .NET DEVELOPERS Sahan Serasinghe @_SahanSera

Slide 2

Slide 2 text

AGENDA 01 The What & Why 02 Tooling 03 Basic language constructs 04 Unit testing 05 Building a HTTP Web Service 06 Multi-Arch Deployments Resources

Slide 3

Slide 3 text

$ WHOAMI Sahan Serasinghe Software Engineer | GitHub Twitter: _SahanSera Blog: sahansera.dev {

Slide 4

Slide 4 text

CODE SAMPLES /sahansera/adnug-go

Slide 5

Slide 5 text

DISCLAIMER This is not to say that one language is superior to another These are just tools and not solutions I’m not a “Go” expert

Slide 6

Slide 6 text

WHAT IS GO?

Slide 7

Slide 7 text

GO Developed by Google in 2009 Released to the public in 2011 Strongly typed, compiled, garbage collected language Current version is 1.17 and 1.18 will be released in early 2022

Slide 8

Slide 8 text

Ken Thompson Rob Pike Robert Griesemer

Slide 9

Slide 9 text

GO IS BUILT WITH VERY SPECIFIC THINGS IN MIND speed of execution speed of compilation dependency management to concurrency and optimization

Slide 10

Slide 10 text

GOOGLE’S DESIGN GOALS FOR GO Create a compiler that works on large codebases as fast as possible Create a compiler that generates fast code using a good set of optimizations

Slide 11

Slide 11 text

GO’S PHILOSOPHY Keep it simple • Keywords C# ~100 vs Go – 25 Consistency • gofmt – Tabs vs Spaces Opinionated • Unused vars are a compiler errors

Slide 12

Slide 12 text

GO & C# - AT A GLANCE No classes = No inheritance No try/catch No generics (yet) No LINQ No Semicolons to end lines

Slide 13

Slide 13 text

WHY SHOULD YOU CARE ABOUT GO?

Slide 14

Slide 14 text

Software Engineers Site Reliability Engineers SecOps Engineers Network Engineers

Slide 15

Slide 15 text

OTHER COOL BITS… •No need to manage runtimes on the deployment environment •Popular projects in the cloud native world

Slide 16

Slide 16 text

TOOLING

Slide 17

Slide 17 text

INSTALLING GO go.dev

Slide 18

Slide 18 text

GO TOOLING Go SDK Go CLI • go run • go build • go get • go vet • gofmt IDEs • VS Code, GoLand, VIM

Slide 19

Slide 19 text

SO, WHERE’S THE CODE?

Slide 20

Slide 20 text

YOUR FIRST GO PROGRAM DEMO

Slide 21

Slide 21 text

AN OVERVIEW GO C#

Slide 22

Slide 22 text

SYNTAX DEMO

Slide 23

Slide 23 text

BASIC CONSTRUCTS • Variables • Packages/imports/modules • Slices & Loops • Conditionals • Functions • Structs • Pointers

Slide 24

Slide 24 text

LIVE CODING TIME

Slide 25

Slide 25 text

UNIT TESTING •Built-in testing commands • go test [-bench] [-cover] • package testing •No assertions library

Slide 26

Slide 26 text

PROJECT STRUCTURE /cmd – Entrypoint(s) of the application /internal – Private application & library code /pkg – Library code visible to others /vendor – Application dependencies ⚠ if you are starting out, this is probably an overkill https://github.com/golang-standards/project-layout

Slide 27

Slide 27 text

BUILDING A HTTP WEB SERVICE + JSON DEMO

Slide 28

Slide 28 text

SIMPLE WEB SERVICE WITH GO & C# GO C#

Slide 29

Slide 29 text

MULTI ARCH DEPLOYMENTS DEMO

Slide 30

Slide 30 text

MORE COOL STUFF? Goroutines GopherJS GoNum TinyGo

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

RESOURCES • https://gobyexample.com/ • https://go.dev/doc/effective_go • https://github.com/golang-standards/project-layout • https://github.com/avelino/awesome-go

Slide 33

Slide 33 text

THANK YOU!

Slide 34

Slide 34 text

QUESTIONS?