SlideShare a Scribd company logo
Go
Because most times Javascript 

isn’t enough
Simon Hewitt / @tyndyll
caveat emptor
I’m an engineer, not a computer scientist… these are the opinions of someone that has been using Go in production for 5+ years and likes it because it gets stuff done,
not because it is some version of computing purity
What is Go? Go (often referred to
as Golang) is a
statically typed,
compiled
programming
language designed at
Google
– Wikipedia
A definition of Go as a programming language. Static typed, so we are having to declare what type are variables are, and compiled, so that to run our code we need to
use the go compiler to execute the code
Why is Go?
Asking the question Why is Go is important, as the context it was created in, and the problems it was trying to solve explains the rationalisation behind the language and
why some decisions were made
– Rob Pike
“The goals of the Go project were to eliminate the
slowness and clumsiness of software development at
Google, and thereby to make the process more productive
and scalable. The language was designed by and for
people who write—and read and debug and maintain—
large software systems.”
Google was originally created at Google in 2007. According to Rob Pike, one of Go’s authors at his talk at Splash 2012 Google was having issues regarding build speeds,
on boarding developers and drift across their code. His presentation gives a lot of context

https://talks.golang.org/2012/splash.article

His talks are always worth a watch.

The conclusion we can come to is that Go was created, not as a exercise in language design, but rather an attempt to solve software engineering problems.
It must work at scale
It must be familiar, roughly C-like.
It must be modern.
dl.google.com
These are the three conclusions that the Go development team came up with initially. Working at scale refers to both running the software, and to the number and size of
teams. Familiar and C like refers to the fact that Java, C++ and Python were the developers that Google had and were hiring at the time so it had to take that into
account. Must be modern refers to the fact that it was being developed in 2007. At this time Google had been working in the web for a considerable time, and new what
was required for success in this environment - HTTP, cryptography, concurrency and memory protection.

dl.google.com was one of the first services written in Go that was released into production. This services handles all downloads at Google - Chrome, Android, SDKs - so
it is heavily loaded and well tested
What is Go?
So lets look at some Go
This is the code we are going to be looking at. It’s a simple Hello World application, but it is a web server, with some concurrency built in, so that when a request to say
hello comes in, it will return, but also pass the request through to a Printer service

The code and more comments and commentary, including how to execute and build the code, will be found at 

https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
This slide shows packages and how they are imported. This `main` package is the entry point to the program. The two packages imported, `fmt` and `net/http` are part of
the standard library. The lower code snippets show how external packages are imported. These are pulled by using the built in tool `go get`, which will clone code from a
repository. This repository can be public or private. Once imported, the packages would be available as `alexa.TypeName`. For more see

https://tour.golang.org/basics/1
This is a demonstration of how structs are implemented. See the gist for further details

https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
What if I want to log?
This is a demonstration of how interfaces are implemented. The interface declares that this interface is satisfied by any struct that has a `Print(string)` function. There are
no additional keywords such as implements. Also note that there are no public or private keywords. This is because this is implemented in go by making functions and
types that have a capital letter Public, and functions and types with a lower case letter private.

Something else of interest - if the developer decides that simply printing the string is not enough and they want a timestamped log entry instead, they can import the log
by adding it to the import statement above, and changing the fmt on line 15 to log. However, this will not compile. One of the features of Go is that it demands that
unused code is removed. This is in response to the problem of non required dependencies existing, and causing confusion in future development. Removing the fmt
package would allow the file to compile again

See the gist for further details, including an additional implementation of a Printer

https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
This is where all of the action happens. As in many programming languages, main is the programs entry point. See the gist for further commentary

https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
Why Should
You Care?
So we’ve seen Go, so why should we pick it up in 2019?
Squillions
of Dollars
Can’t Be
Wrong*
* This is a terrible reason
This page lists a number of companies and products that are using Go heavily. This is not to indicate that writing in Go will create a billion dollar unicorn, but more to
demonstrate that many types of products (networking, APIs, tooling, databases, smart contracts) are being developed and heavily used in production across the industry
Similarly, with our Belfast focus, these are companies locally that are using Go everyday. Learning Go isn’t niche, and there are jobs and opportunities available
Tooling
• Built in Libraries

• Built in tools…

• Testing

• Deployment
Tooling is one of the primary features of Go, and it’s one of the reasons that Go is scalable across teams. Aside from the fantastic standard library (https://golang.org/
pkg/), Go has a huge number of tools as part of the distribution (https://golang.org/cmd/). The standout is gofmt, which formats code into the Right Way. This makes Go
code extremely readable no matter what team has written it. go test is also built in, which makes testing a first class component of Go. 

Deployment is interesting also. Go is a compiled language, producing a single binary with all libraries statically compiled into it. Compiling for different platforms or
architectures is as simple as setting the GOOS (darwin, linux, windows) or GOARCH (386, amd64, arm etc) environmental variables respectively. There is more
information in the `Compiling` section of the gist. Also of interest - Go is now available as AWS Lambdas or Google Cloud Functions, as well as being an ideal candidate
for docker containers.
Learning and Support
•Tiny base language
•Decisions made for
you
•Good docs
•IDE’s
•Helpful community
•Playground
•Fast development
cycle
I believe that Go makes an excellent teaching language, and as such is easy to pick up (25 keywords with a fully populated standard library). While static typing may
seem more complicated than dynamic typing, the compiler is helpful in its error messages. 

Go is opinionated, deciding what the style of code should be and enforcing it both through gofmt and the compiler. You may have strong opinions about where curly
braces should be placed, but Go really doesn’t care. This is enforced through the compiler, for example, by not requiring semi colons to terminate statements and only
accepting newlines or braces.

The docs are great, and are locally available in the distribution by executing godoc -http :6060 (makes them available in a browser on port 6060). They are also built into
your code in a similar way to Javadocs (https://blog.golang.org/godoc-documenting-go-code)

Recommended IDE’s 

Goland - https://www.jetbrains.com/go/

VS Code - https://code.visualstudio.com/docs/languages/go

If you want to just dabble rather than setting everything up have a look at Golang Playground 

http://play.golang.org

What can’t be underestimated is the fast compile times. Compiling even large projects takes seconds, to the point where running `go run code.go` makes for a really
good scripting environment
So It’s Perfect? Well…
• Dependencies are
complicated
• Generics
• Error handling
These are currently being
actively addressed by the
community
I could explain these, but it’s easier to go straight to the source. The community is getting better at discussing their issues in public and using the community to help

Dependencies issues and conversation - https://github.com/golang/go/wiki/Modules

Generics issue and conversation - https://go.googlesource.com/proposal/+/master/design/go2draft-generics-overview.md

Error handling - https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md
• Easy to pick up

• Scales to Teams

• Feature packed standard
library

• Fantastic Tooling

• Good community

• 2.0 is coming
So Why Go?
Summing everything up
• Web services

• Networking services

• Command line tools

• Glue…

• Multi platform

• Lambda/Cloud Functions
So When Go?
When would you use it? Ironically on the morning of the talk Garth Gilmour (https://twitter.com/GarthGilmour) retweeted this

https://twitter.com/GarthGilmour/status/1084760622397575168

If you want to try Go, it’s design makes this really straightforward. Download and install, and get started. Everything is possible in a single file, managing dependencies is
straightforward, if it is required (again, you can go far on the standard library alone). If you have a simple idea for anything like the above, I strongly encourage you to give
Go a look. If I can help, my Twitter handle is on the next slide

With regard to “Glue” above. Using C libraries in Go is pretty straightforward. If you have something you need a C library for, why not wrap it in Go? 

https://blog.golang.org/c-go-cgo
GOTO
• https://tour.golang.org/

• https://gobyexample.com

• Belfast Gophers

• Training?

• @tyndyll on Twitter
Twitter is the easiest place to find me

More Related Content

PDF
Developing for LinkedIn's Application Platform
PDF
Why you should care about Go (Golang)
PPTX
Introduction to GoLang
PPTX
NodeJS vs Golang - A detailed comparison
PDF
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
PPTX
Scaling applications with go
PDF
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
PPT
Introduction to Go-Lang
Developing for LinkedIn's Application Platform
Why you should care about Go (Golang)
Introduction to GoLang
NodeJS vs Golang - A detailed comparison
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Scaling applications with go
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
Introduction to Go-Lang

What's hot (20)

PDF
[INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn
PDF
When, how & why use golang in 2021 go benefits & use cases
PPTX
PDF
The Go programming language - Intro by MyLittleAdventure
PDF
0581OS_FM_Final_NT
PDF
Advantages of golang development services & 10 most used go frameworks
PDF
Microservices in Golang
PDF
GoLang Introduction
PPTX
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
PDF
(Live) build and run golang web server on android.avi
PDF
Golang skills session1: introduction
PPTX
Kotlin – Alternative oder Ergänzung zu Java?
PDF
Water Softening Of the House Water with the Help of Water Softener Systems
PDF
really really really awesome php application with bdd behat and iterfaces
PPTX
GraphQL - hot or not? How to simplify API based services?
PDF
Let's Go @ St. Louis CocoaHeads
PDF
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
PDF
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
PDF
New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...
PDF
The Why of Go
[INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn
When, how & why use golang in 2021 go benefits & use cases
The Go programming language - Intro by MyLittleAdventure
0581OS_FM_Final_NT
Advantages of golang development services & 10 most used go frameworks
Microservices in Golang
GoLang Introduction
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
(Live) build and run golang web server on android.avi
Golang skills session1: introduction
Kotlin – Alternative oder Ergänzung zu Java?
Water Softening Of the House Water with the Help of Water Softener Systems
really really really awesome php application with bdd behat and iterfaces
GraphQL - hot or not? How to simplify API based services?
Let's Go @ St. Louis CocoaHeads
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...
The Why of Go
Ad

Similar to Introduction to Go (20)

PPTX
Introduction to go lang
PDF
Enterprise 2020
PDF
Why Go Lang?
PPTX
GO compiler.pptx download for learning gi
PPTX
Untangling4
PDF
Getting started with go - Florin Patan - Codemotion Milan 2016
PDF
Golang : A Hype or the Future?
PDF
Lets Go - An introduction to Google's Go Programming Language
PDF
Let's Go: Introduction to Google's Go Programming Language
PPT
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
PDF
Beginning development in go
PDF
Hire golang developers and make the shift to brighter business future (build ...
PPT
A First Look at Google's Go Programming Language
PPT
Google's Go Programming Language - Introduction
PDF
GitHub Actions in Action MEAP V03 Michael Kaufmann
PDF
Go Within Cloud Foundry
KEY
Grails at DMC Digital
PDF
GitHub Actions in Action MEAP V03 Michael Kaufmann
PDF
Dart By Example 1st Edition Davy Mitchell 2024 scribd download
PPTX
Comparing C and Go
Introduction to go lang
Enterprise 2020
Why Go Lang?
GO compiler.pptx download for learning gi
Untangling4
Getting started with go - Florin Patan - Codemotion Milan 2016
Golang : A Hype or the Future?
Lets Go - An introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming Language
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Beginning development in go
Hire golang developers and make the shift to brighter business future (build ...
A First Look at Google's Go Programming Language
Google's Go Programming Language - Introduction
GitHub Actions in Action MEAP V03 Michael Kaufmann
Go Within Cloud Foundry
Grails at DMC Digital
GitHub Actions in Action MEAP V03 Michael Kaufmann
Dart By Example 1st Edition Davy Mitchell 2024 scribd download
Comparing C and Go
Ad

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
top salesforce developer skills in 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Which alternative to Crystal Reports is best for small or large businesses.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How to Migrate SBCGlobal Email to Yahoo Easily
Upgrade and Innovation Strategies for SAP ERP Customers
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ManageIQ - Sprint 268 Review - Slide Deck
Wondershare Filmora 15 Crack With Activation Key [2025
VVF-Customer-Presentation2025-Ver1.9.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PTS Company Brochure 2025 (1).pdf.......
top salesforce developer skills in 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
2025 Textile ERP Trends: SAP, Odoo & Oracle
Design an Analysis of Algorithms I-SECS-1021-03
medical staffing services at VALiNTRY
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia

Introduction to Go

  • 1. Go Because most times Javascript isn’t enough Simon Hewitt / @tyndyll
  • 2. caveat emptor I’m an engineer, not a computer scientist… these are the opinions of someone that has been using Go in production for 5+ years and likes it because it gets stuff done, not because it is some version of computing purity
  • 3. What is Go? Go (often referred to as Golang) is a statically typed, compiled programming language designed at Google – Wikipedia A definition of Go as a programming language. Static typed, so we are having to declare what type are variables are, and compiled, so that to run our code we need to use the go compiler to execute the code
  • 4. Why is Go? Asking the question Why is Go is important, as the context it was created in, and the problems it was trying to solve explains the rationalisation behind the language and why some decisions were made
  • 5. – Rob Pike “The goals of the Go project were to eliminate the slowness and clumsiness of software development at Google, and thereby to make the process more productive and scalable. The language was designed by and for people who write—and read and debug and maintain— large software systems.” Google was originally created at Google in 2007. According to Rob Pike, one of Go’s authors at his talk at Splash 2012 Google was having issues regarding build speeds, on boarding developers and drift across their code. His presentation gives a lot of context https://talks.golang.org/2012/splash.article His talks are always worth a watch. The conclusion we can come to is that Go was created, not as a exercise in language design, but rather an attempt to solve software engineering problems.
  • 6. It must work at scale It must be familiar, roughly C-like. It must be modern. dl.google.com These are the three conclusions that the Go development team came up with initially. Working at scale refers to both running the software, and to the number and size of teams. Familiar and C like refers to the fact that Java, C++ and Python were the developers that Google had and were hiring at the time so it had to take that into account. Must be modern refers to the fact that it was being developed in 2007. At this time Google had been working in the web for a considerable time, and new what was required for success in this environment - HTTP, cryptography, concurrency and memory protection. dl.google.com was one of the first services written in Go that was released into production. This services handles all downloads at Google - Chrome, Android, SDKs - so it is heavily loaded and well tested
  • 7. What is Go? So lets look at some Go
  • 8. This is the code we are going to be looking at. It’s a simple Hello World application, but it is a web server, with some concurrency built in, so that when a request to say hello comes in, it will return, but also pass the request through to a Printer service The code and more comments and commentary, including how to execute and build the code, will be found at https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
  • 9. This slide shows packages and how they are imported. This `main` package is the entry point to the program. The two packages imported, `fmt` and `net/http` are part of the standard library. The lower code snippets show how external packages are imported. These are pulled by using the built in tool `go get`, which will clone code from a repository. This repository can be public or private. Once imported, the packages would be available as `alexa.TypeName`. For more see https://tour.golang.org/basics/1
  • 10. This is a demonstration of how structs are implemented. See the gist for further details https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
  • 11. What if I want to log? This is a demonstration of how interfaces are implemented. The interface declares that this interface is satisfied by any struct that has a `Print(string)` function. There are no additional keywords such as implements. Also note that there are no public or private keywords. This is because this is implemented in go by making functions and types that have a capital letter Public, and functions and types with a lower case letter private. Something else of interest - if the developer decides that simply printing the string is not enough and they want a timestamped log entry instead, they can import the log by adding it to the import statement above, and changing the fmt on line 15 to log. However, this will not compile. One of the features of Go is that it demands that unused code is removed. This is in response to the problem of non required dependencies existing, and causing confusion in future development. Removing the fmt package would allow the file to compile again See the gist for further details, including an additional implementation of a Printer https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
  • 12. This is where all of the action happens. As in many programming languages, main is the programs entry point. See the gist for further commentary https://gist.github.com/tyndyll/cce72c16dc112cbe7ffac44dbb1dc5e8
  • 13. Why Should You Care? So we’ve seen Go, so why should we pick it up in 2019?
  • 14. Squillions of Dollars Can’t Be Wrong* * This is a terrible reason
  • 15. This page lists a number of companies and products that are using Go heavily. This is not to indicate that writing in Go will create a billion dollar unicorn, but more to demonstrate that many types of products (networking, APIs, tooling, databases, smart contracts) are being developed and heavily used in production across the industry
  • 16. Similarly, with our Belfast focus, these are companies locally that are using Go everyday. Learning Go isn’t niche, and there are jobs and opportunities available
  • 17. Tooling • Built in Libraries • Built in tools… • Testing • Deployment Tooling is one of the primary features of Go, and it’s one of the reasons that Go is scalable across teams. Aside from the fantastic standard library (https://golang.org/ pkg/), Go has a huge number of tools as part of the distribution (https://golang.org/cmd/). The standout is gofmt, which formats code into the Right Way. This makes Go code extremely readable no matter what team has written it. go test is also built in, which makes testing a first class component of Go. Deployment is interesting also. Go is a compiled language, producing a single binary with all libraries statically compiled into it. Compiling for different platforms or architectures is as simple as setting the GOOS (darwin, linux, windows) or GOARCH (386, amd64, arm etc) environmental variables respectively. There is more information in the `Compiling` section of the gist. Also of interest - Go is now available as AWS Lambdas or Google Cloud Functions, as well as being an ideal candidate for docker containers.
  • 18. Learning and Support •Tiny base language •Decisions made for you •Good docs •IDE’s •Helpful community •Playground •Fast development cycle I believe that Go makes an excellent teaching language, and as such is easy to pick up (25 keywords with a fully populated standard library). While static typing may seem more complicated than dynamic typing, the compiler is helpful in its error messages. Go is opinionated, deciding what the style of code should be and enforcing it both through gofmt and the compiler. You may have strong opinions about where curly braces should be placed, but Go really doesn’t care. This is enforced through the compiler, for example, by not requiring semi colons to terminate statements and only accepting newlines or braces. The docs are great, and are locally available in the distribution by executing godoc -http :6060 (makes them available in a browser on port 6060). They are also built into your code in a similar way to Javadocs (https://blog.golang.org/godoc-documenting-go-code) Recommended IDE’s Goland - https://www.jetbrains.com/go/ VS Code - https://code.visualstudio.com/docs/languages/go If you want to just dabble rather than setting everything up have a look at Golang Playground http://play.golang.org What can’t be underestimated is the fast compile times. Compiling even large projects takes seconds, to the point where running `go run code.go` makes for a really good scripting environment
  • 19. So It’s Perfect? Well… • Dependencies are complicated • Generics • Error handling These are currently being actively addressed by the community I could explain these, but it’s easier to go straight to the source. The community is getting better at discussing their issues in public and using the community to help Dependencies issues and conversation - https://github.com/golang/go/wiki/Modules Generics issue and conversation - https://go.googlesource.com/proposal/+/master/design/go2draft-generics-overview.md Error handling - https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md
  • 20. • Easy to pick up • Scales to Teams • Feature packed standard library • Fantastic Tooling • Good community • 2.0 is coming So Why Go? Summing everything up
  • 21. • Web services • Networking services • Command line tools • Glue… • Multi platform • Lambda/Cloud Functions So When Go? When would you use it? Ironically on the morning of the talk Garth Gilmour (https://twitter.com/GarthGilmour) retweeted this https://twitter.com/GarthGilmour/status/1084760622397575168 If you want to try Go, it’s design makes this really straightforward. Download and install, and get started. Everything is possible in a single file, managing dependencies is straightforward, if it is required (again, you can go far on the standard library alone). If you have a simple idea for anything like the above, I strongly encourage you to give Go a look. If I can help, my Twitter handle is on the next slide With regard to “Glue” above. Using C libraries in Go is pretty straightforward. If you have something you need a C library for, why not wrap it in Go? https://blog.golang.org/c-go-cgo
  • 22. GOTO • https://tour.golang.org/ • https://gobyexample.com • Belfast Gophers • Training? • @tyndyll on Twitter Twitter is the easiest place to find me