Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go for .NET Developers

Go for .NET Developers

These are the presentation slides I created for the talk I gave at the Adelaide .NET User Group on 8th December 2021.

https://www.meetup.com/en-AU/Adelaide-dotNET/events/282173557/

Sahan Serasinghe

December 09, 2021
Tweet

More Decks by Sahan Serasinghe

Other Decks in Technology

Transcript

  1. GO FOR .NET DEVELOPERS
    Sahan Serasinghe
    @_SahanSera

    View Slide

  2. 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

    View Slide

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

    View Slide

  4. CODE SAMPLES
    /sahansera/adnug-go

    View Slide

  5. 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

    View Slide

  6. WHAT IS GO?

    View Slide

  7. 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

    View Slide

  8. Ken Thompson
    Rob Pike
    Robert Griesemer

    View Slide

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

    View Slide

  10. 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

    View Slide

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

    View Slide

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

    View Slide

  13. WHY SHOULD YOU CARE ABOUT
    GO?

    View Slide

  14. Software Engineers
    Site
    Reliability
    Engineers
    SecOps
    Engineers
    Network
    Engineers

    View Slide

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

    View Slide

  16. TOOLING

    View Slide

  17. INSTALLING
    GO
    go.dev

    View Slide

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

    View Slide

  19. SO, WHERE’S THE CODE?

    View Slide

  20. YOUR FIRST GO PROGRAM
    DEMO

    View Slide

  21. AN OVERVIEW
    GO C#

    View Slide

  22. SYNTAX
    DEMO

    View Slide

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

    View Slide

  24. LIVE CODING
    TIME

    View Slide

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

    View Slide

  26. 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

    View Slide

  27. BUILDING A HTTP WEB SERVICE + JSON
    DEMO

    View Slide

  28. SIMPLE WEB SERVICE WITH GO & C#
    GO C#

    View Slide

  29. MULTI ARCH DEPLOYMENTS
    DEMO

    View Slide

  30. MORE COOL
    STUFF?
    Goroutines
    GopherJS
    GoNum
    TinyGo

    View Slide

  31. View Slide

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

    View Slide

  33. THANK YOU!

    View Slide

  34. QUESTIONS?

    View Slide