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

What's hot

[INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn
[INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn [INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn
[INNOVATUBE] Tech Talk #3: Golang - Vũ Nguyễn
Nexus FrontierTech
 
When, how & why use golang in 2021 go benefits & use cases
When, how & why use golang in 2021  go benefits & use casesWhen, how & why use golang in 2021  go benefits & use cases
When, how & why use golang in 2021 go benefits & use cases
Katy Slemon
 
Golang
GolangGolang
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventure
mylittleadventure
 
0581OS_FM_Final_NT
0581OS_FM_Final_NT0581OS_FM_Final_NT
0581OS_FM_Final_NTVibhor Kumar
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworks
Katy Slemon
 
Microservices in Golang
Microservices in GolangMicroservices in Golang
Microservices in Golang
Mo'ath Qasim
 
GoLang Introduction
GoLang IntroductionGoLang Introduction
GoLang Introduction
Spandana Govindgari
 
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
ATO 2014 - So You Think You Know 'Go'? The Go Programming LanguageATO 2014 - So You Think You Know 'Go'? The Go Programming Language
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
John Potocny
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
SeongJae Park
 
Golang skills session1: introduction
Golang skills session1: introductionGolang skills session1: introduction
Golang skills session1: introduction
sofianinho
 
Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?
gedoplan
 
Water Softening Of the House Water with the Help of Water Softener Systems
Water Softening Of the House Water with the Help of Water Softener SystemsWater Softening Of the House Water with the Help of Water Softener Systems
Water Softening Of the House Water with the Help of Water Softener Systems
Jessica Simpson
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfaces
Giulio De Donato
 
GraphQL - hot or not? How to simplify API based services?
GraphQL - hot or not? How to simplify  API based services?GraphQL - hot or not? How to simplify  API based services?
GraphQL - hot or not? How to simplify API based services?
Adam Klimczyk
 
Let's Go @ St. Louis CocoaHeads
Let's Go @ St. Louis CocoaHeadsLet's Go @ St. Louis CocoaHeads
Let's Go @ St. Louis CocoaHeads
Paul Balogh
 
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
Evan Lin
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
 
New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...
New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...
New trends of web technology on mobile: HTML5, PhoneGap & NaCl - Barcamp Saig...Vũ Nguyễn
 
The Why of Go
The Why of GoThe Why of Go
The Why of Go
C4Media
 

What's hot (20)

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

Similar to Introduction to Go

Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
Amal Mohan N
 
Enterprise 2020
Enterprise 2020Enterprise 2020
Enterprise 2020
Siarhei Hladkou
 
Why Go Lang?
Why Go Lang?Why Go Lang?
Why Go Lang?
Sathish VJ
 
Untangling4
Untangling4Untangling4
Untangling4
Derek Jacoby
 
Getting started with go - Florin Patan - Codemotion Milan 2016
Getting started with go - Florin Patan - Codemotion Milan 2016Getting started with go - Florin Patan - Codemotion Milan 2016
Getting started with go - Florin Patan - Codemotion Milan 2016
Codemotion
 
Golang : A Hype or the Future?
Golang : A Hype or the Future?Golang : A Hype or the Future?
Golang : A Hype or the Future?
Mindfire LLC
 
Let's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming LanguageLet's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming Language
Ganesh Samarthyam
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language
Ganesh Samarthyam
 
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Amanda Lam
 
Beginning development in go
Beginning development in goBeginning development in go
Beginning development in go
Equaleyes Solutions Ltd.
 
Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...
Katy Slemon
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
Ganesh Samarthyam
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
Go Within Cloud Foundry
Go Within Cloud FoundryGo Within Cloud Foundry
Go Within Cloud FoundryPlatform CF
 
Grails at DMC Digital
Grails at DMC DigitalGrails at DMC Digital
Grails at DMC Digital
tomaslin
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
Marcin Pasinski
 
[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure
Rodrigo Stefani Domingues
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?
sangam biradar
 
Introduction to go, and why it's awesome
Introduction to go, and why it's awesomeIntroduction to go, and why it's awesome
Introduction to go, and why it's awesome
Janet Kuo
 
Features of go
Features of goFeatures of go
Features of go
Manjitsing Valvi
 

Similar to Introduction to Go (20)

Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
 
Enterprise 2020
Enterprise 2020Enterprise 2020
Enterprise 2020
 
Why Go Lang?
Why Go Lang?Why Go Lang?
Why Go Lang?
 
Untangling4
Untangling4Untangling4
Untangling4
 
Getting started with go - Florin Patan - Codemotion Milan 2016
Getting started with go - Florin Patan - Codemotion Milan 2016Getting started with go - Florin Patan - Codemotion Milan 2016
Getting started with go - Florin Patan - Codemotion Milan 2016
 
Golang : A Hype or the Future?
Golang : A Hype or the Future?Golang : A Hype or the Future?
Golang : A Hype or the Future?
 
Let's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming LanguageLet's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming Language
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language
 
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
Introduction to Application Development in Python and Gtk+ / Hildon @ Maemo 5
 
Beginning development in go
Beginning development in goBeginning development in go
Beginning development in go
 
Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
 
Go Within Cloud Foundry
Go Within Cloud FoundryGo Within Cloud Foundry
Go Within Cloud Foundry
 
Grails at DMC Digital
Grails at DMC DigitalGrails at DMC Digital
Grails at DMC Digital
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
 
[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?
 
Introduction to go, and why it's awesome
Introduction to go, and why it's awesomeIntroduction to go, and why it's awesome
Introduction to go, and why it's awesome
 
Features of go
Features of goFeatures of go
Features of go
 

Recently uploaded

Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 

Recently uploaded (20)

Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 

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