SlideShare a Scribd company logo
WHY AND
WHAT IS GO
Marko Jantke / Christian Speckner, Mayflower GmbH
A BRIEF
HISTORY
CONCEIVED 2007 AT
GOOGLE
Robert Griesemer
Rob Pike
Ken Thomson
...OF BELL LABS / UNIX FAME
...OF PLAN 9 FAME
The worst sci-fi movie ever
An experimental OS developed at Bell
Heritage visible in Go (toolchain!)
SOME DATES
First commit: 03/2008
Release 1.0 03/2012
Last release 1.7.1: 22 days ago
WHERE IS
GO?
POPULAR PROJECTS
WRITTEN IN GO
Docker
Kubernetes
etcd
Caddy
Consul
Mattermost
...
WHY IS GO?
THE AUTHORITATIVE
DOCUMENT
Go at Google: Language Design in the Service of Software
Engineering.
[https://talks.golang.org/2012/splash.article]
(And you'll be stumbling over Plan 9 more than once)
SOME DESIGN GOALS
Fast compilation cycles
Simple and concise syntax: easy to read, easy to parse
Familiarity for new developers
Scales well to large code bases
Promote robust and maintainable design
Keep large codebases robust in face of change
Offer maintainable paradigms for multithreading
INSIDE THE
GOPHER
STATICALLY TYPED
//Variabledeclaration
varsomeintint
varsomestringstring
varsomemapmap[string]int
//Typeinference
someint:=10
somestring:="Helloworld"
somemap:=make(map[string]int)
//Typedefinition
typeSometypestruct{
Field1int
Field2[]bool
}
//Functiondeclaration
funcFooinator(param1int,param2SomeStruct)string{
//Dosomething
}
IMPLICIT INTERFACES,
BUT NO CLASSES
packagemain
import(
"fmt"
"log"
"os"
)
typeDocinterface{}
typeDocumentStorageinterface{
Store(int,Doc)(error)
Get(int)(Doc,error)
}
typeMemoryStoragestruct{
docsmap[int]Doc
GARBAGE COLLECTED...
typeSomeStructstruct{
Field1string
Field2string
}
funcGenerator()SomeStruct{
returnSomeStruct{
Field1:"Hello",
Field2:"World",
}
}
... WITH POINTERS ...
typeSomeStructstruct{
Field1string
Field2string
}
funcGenerator()*SomeStruct{
return&SomeStruct{
Field1:"Hello",
Field2:"World",
}
}
... AND CLOSURES
funcFibonacciGenerator()(func()int){
f0:=0
f1:=1
returnfunc(){
oldF0:=f0
f0=f1
f1=oldF0+f1
returnf1
}
}
//...
f:=FibonacciGenerator()
fmt.Println(f(),f(),f(),f(),f(),f())//1235813
LIGHTWEIGHT THREADS
-> GOROUTINES
Scheduling (cooperative multithreading with multiple
threads)
Blocking
Communication (channels)
Races & mutexes
Embed code from golang/samples/interfaces.go
LIGHTWEIGHT THREADS ->
GOROUTINES
packagemain
import(
"fmt"
"time"
)
funcsaySomething(sstring,timesint){
fori:=0;i<times;i++{
time.Sleep(100*time.Millisecond)
fmt.Println(s)
}
}
funcmain(){
gosaySomething("hello",3)
gosaySomething("world",3)
saySomething("!",3)
}
//output:worldhello!worldhello!world!hello
LIGHTWEIGHT THREADS ->
GOROUTINES
packagemain
import(
"fmt"
)
funcsayHello(timesint,outputChannelchan<-string){
fori:=0;i<times;i++{
outputChannel<-"Hello"
}
}
funcsayWorld(timesint,inputChannel<-chanstring,outputChannelchan<-string
fori:=0;i<times;i++{
output:=<-inputChannel+"World!"
outputChannel<-output
}
}
funcprintString(timesint,inputChannel<-chanstring,outputChannelchan<-bool
fori:=0;i<times;i++{
output:=<-inputChannel
NO EXCEPTION
HANDLING, BUT...
Errors as values
Multiple return values
Defers
Panics and recover
NO EXCEPTION HANDLING, BUT...
packagemain
import(
"os"
"flag"
"log"
)
funcFileSize(pathstring)(int64,error){
fileInfo,err:=os.Stat(path)
iferr!=nil{
return0,err
}
returnfileInfo.Size(),nil
}
funcmain(){
varfilePathstring
flag.StringVar(&filePath,"filePath","","thefiletogetthesizeof"
flag.Parse()
HUGE STANDARD
LIBRARY
—
BATTERIES INCLUDED
HTTP SERVER
typehandlerint
func(h*handler)ServeHTTP(
responsehttp.ResponseWriter,
request*http.Request,
){
response.WriteHeader(http.StatusOK)
fmt.Fprintf(response,"thisisrequest#%vn",*h)
*h++
}
funcmain(){
i:=0
http.ListenAndServe(":8888",(*handler)(&i))
}
HTTP CLIENT
resp,err:=http.Get("http://www.mayflower.de")
varresponseBuffer[]byte
iferr==nil{
responseBuffer,err=ioutil.ReadAll(resp.Body)
}
iferr==nil{
fmt.Println(string(responseBuffer))
}else{
fmt.Printf("ERROR:%vn",err)
}
STREAM COMPRESSION
resp,err:=http.Get("http://www.mayflower.de")
iferr==nil{
writer:=gzip.NewWriter(os.Stdout)
_,err=io.Copy(writer,resp.Body)
iferr==nil{
writer.Close()
}
}
iferr!=nil{
fmt.Fprintf(os.Stderr,"ERROR:%vn",err)
}
AND MUCH, MUCH MORE...
Crypto, hashing
Marshalling / Unmarshalling (JSON, Base64, XML, ...)
Command line parsing
Complex numbers
JSON RPC
Reflection
Golang lexer and parser!
TOOLING
SWISS KNIVE: GO
goas interface to complete toolchain
go get
go build -x
go install
go test -race
go test -coverprofile=c.out
go tool cover -html=c.out
TOOLCHAIN
"NATIVE" TOOLCHAIN
This is the toolchain referred to in golang release
Rooted in Plan 9 toolchain (assembler, linker)
Used to be C, now Golang (converted from C)
Produces static binaries (not quite true anymore)
OS: Win, Linux, OSX, BSD and friends, Plan 9 (!), ...
Arch: x86, x86-64, ARM(v5678), ppc
Dead simple cross compilation
GOARCH=x86GOOS=windowsgoinstallsome/package
GCC FRONTEND
Lags behind native toolchain (currently 1.4 in GCC5)
Relies on GCC & friends for optimization, code
generation and linking
Generates dynamic binaries
Supports anything supported by GCC (MIPS anybody)
Cross compilation: PITA
INTERFACING C
Works with CGO: generates glue code
Dynamic dependencies: breaks cross compiling badly :(
BUT: Lots of native go out there :)
TESTING, PROFILING
AND CODE COVERAGE
[MARCO]
Testing files located by convention main.go ->
main_test.go
go test -cover -cpuprofile cpu.out -
memprofile mem.out
TESTING, PROFILING AND CODE
COVERAGE
packagemain
import"testing"
funcTestDivide(t*testing.T){
v,_:=Divide(10,5)
ifv!=2{
t.Error("Expected2,got:",v)
}
}
DEPENDENCY
MANAGEMENT
import"github.com/googollee/go-socket.io"
DEPENDENCIES CAN BE
AUTOMATICALLY IMPORTED
FROM GITHUB?
AWESOME!
AWESOME?
Pulls directly from git master
Stability?
Versioning?
API breaks?
REPRODUCIBLE BUILDS?
SOLUTION 1: GOPKG.IN
import"gopkg.in/yaml.v1"
$curlhttp://gopkg.in/yaml.v1?go-get=1
<html>
<head>
<metaname="go-import"content="gopkg.in/yaml.v1githttps://gopkg.in/yaml.v1">
<metaname="go-source"content="gopkg.in/yaml.v1_
https://github.com/go-yaml/yaml/tree/v1{/dir}
https://github.com/go-yaml/yaml/blob/v1{/dir}/{file}#L{line}">
</head>
<body>
gogetgopkg.in/yaml.v1
</body>
</html>
Redirects to fixed tags on github
Works well for small libraries
SOLUTION 2:
VENDORING
Record and pin dependencies in per-package manifest
Recursively download deps before build
Needs external tooling and per-package support :(
Popular specimen: glide
GOPHER
FODDER
PERFORMANT SERVERS
Event loop AND threads
Compiled and statically typed
Standard lib covers most networking stuff
Community frameworks for services: go-micro, go-kit
DEPENDENCY-LESS
UNIX-STYLE CLI TOOLS
Direct access to syscalls
Huge standard library
Supports script-like code style
Static binaries
EASY ACCESSIBLE
Fast entrance to the language
Great documentation
Parallel programming for everyone
NOT SO GOOD FOR
GOPHERS
GUI
Embedded
THANK YOU FOR
LISTENING
QUESTIONS?
Christian Speckner <christian.speckner@mayflower.de>
Marco Jantke <marco.jantke@mayflower.de>

More Related Content

PDF
Salt and pepper — native code in the browser Browser using Google native Client
PDF
Chromium: NaCl and Pepper API
PPTX
Short introduction - .net core and .net standard 2.0
PDF
Flask for cs students
PDF
Sep Nasiri "Upwork PHP Architecture"
PDF
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
PDF
.NET Core Blimey! Windows Platform User Group, Manchester
PDF
.NET Core in the Real World
Salt and pepper — native code in the browser Browser using Google native Client
Chromium: NaCl and Pepper API
Short introduction - .net core and .net standard 2.0
Flask for cs students
Sep Nasiri "Upwork PHP Architecture"
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
.NET Core Blimey! Windows Platform User Group, Manchester
.NET Core in the Real World

What's hot (20)

PDF
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
PDF
Docker 導入:障礙與對策
ODP
openSUSE Conference 2017 - The Docker at Travis Presentation
PPTX
TYPO3 & Composer
PDF
openSUSE Conference 2017 - YaST News
PDF
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
PPTX
Net core
PDF
Go from PHP engineer's perspective
PDF
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
PDF
Workshop - Golang language
ODP
Groovy shell scripting
PDF
Ondřej Procházka - Deployment podle Devel.cz
PDF
Angular v2 et plus : le futur du développement d'applications en entreprise
PDF
Continuous Delivery di una WebApp - by example
PDF
Adopting GraalVM - Scale by the Bay 2018
PDF
How to write a Dockerfile
PPTX
CI-CD WITH GITLAB WORKFLOW
PDF
Opensource pnp container based waf
PDF
Cache in Chromium: Disk Cache
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
Docker 導入:障礙與對策
openSUSE Conference 2017 - The Docker at Travis Presentation
TYPO3 & Composer
openSUSE Conference 2017 - YaST News
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
Net core
Go from PHP engineer's perspective
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
Workshop - Golang language
Groovy shell scripting
Ondřej Procházka - Deployment podle Devel.cz
Angular v2 et plus : le futur du développement d'applications en entreprise
Continuous Delivery di una WebApp - by example
Adopting GraalVM - Scale by the Bay 2018
How to write a Dockerfile
CI-CD WITH GITLAB WORKFLOW
Opensource pnp container based waf
Cache in Chromium: Disk Cache
Ad

Viewers also liked (7)

PDF
Rewrites überleben
PDF
JavaScript Days 2015: Security
PDF
Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...
PDF
HEAR & NOW | Die Zukunft von Audio zwischen Content, Kontext und Kommunikation
PDF
Agile Anti-Patterns
PDF
WERTEvoll agieren - agile Unternehmenskultur zum Leben erwecken
PDF
Slideshow: So nutzen Sie visuelle Trends im Alltag
Rewrites überleben
JavaScript Days 2015: Security
Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...
HEAR & NOW | Die Zukunft von Audio zwischen Content, Kontext und Kommunikation
Agile Anti-Patterns
WERTEvoll agieren - agile Unternehmenskultur zum Leben erwecken
Slideshow: So nutzen Sie visuelle Trends im Alltag
Ad

Similar to Why and what is go (20)

PPTX
Golang - Overview of Go (golang) Language
PPTX
Ready, set, go! An introduction to the Go programming language
PDF
Why Go Lang?
PDF
Introduction to Go
PDF
GoLang Introduction
PDF
Go. why it goes v2
PPTX
go language- haseeb.pptx
PDF
PPTX
Go. Why it goes
PDF
The State of Go - Andrew Gerrand
PPTX
The GO Language : From Beginners to Gophers
PDF
Write in Go
PDF
Highlights of Google Go
PDF
Mender.io | Develop embedded applications faster | Comparing C and Golang
PPTX
Introduction to go lang
PDF
Why you should care about Go (Golang)
PDF
Introduction to Google's Go programming language
PPTX
Comparing C and Go
PPTX
Scaling applications with go
PDF
Golang
Golang - Overview of Go (golang) Language
Ready, set, go! An introduction to the Go programming language
Why Go Lang?
Introduction to Go
GoLang Introduction
Go. why it goes v2
go language- haseeb.pptx
Go. Why it goes
The State of Go - Andrew Gerrand
The GO Language : From Beginners to Gophers
Write in Go
Highlights of Google Go
Mender.io | Develop embedded applications faster | Comparing C and Golang
Introduction to go lang
Why you should care about Go (Golang)
Introduction to Google's Go programming language
Comparing C and Go
Scaling applications with go
Golang

More from Mayflower GmbH (20)

PDF
Vom Entwickler zur Führungskraft
PPTX
Produktive teams
PDF
Plugging holes — javascript memory leak debugging
PDF
Usability im web
PDF
JavaScript Security
PDF
50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...
PDF
Responsive Webdesign
PDF
Native Cross-Platform-Apps mit Titanium Mobile und Alloy
PDF
Pair Programming Mythbusters
PDF
Shoeism - Frau im Glück
PDF
Bessere Software schneller liefern
PDF
Von 0 auf 100 in 2 Sprints
PDF
Piwik anpassen und skalieren
PDF
Agilitaet im E-Commerce - E-Commerce Breakfast
KEY
Mongo DB - Segen oder Fluch
PDF
Schnelle Geschäfte
PDF
Test-Driven JavaScript Development IPC
PDF
PHP Dependency und Paket Management mit Composer
PDF
HTML5 und node.js Grundlagen
PDF
Max Köhler - Real-Time-Monitoring
Vom Entwickler zur Führungskraft
Produktive teams
Plugging holes — javascript memory leak debugging
Usability im web
JavaScript Security
50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...
Responsive Webdesign
Native Cross-Platform-Apps mit Titanium Mobile und Alloy
Pair Programming Mythbusters
Shoeism - Frau im Glück
Bessere Software schneller liefern
Von 0 auf 100 in 2 Sprints
Piwik anpassen und skalieren
Agilitaet im E-Commerce - E-Commerce Breakfast
Mongo DB - Segen oder Fluch
Schnelle Geschäfte
Test-Driven JavaScript Development IPC
PHP Dependency und Paket Management mit Composer
HTML5 und node.js Grundlagen
Max Köhler - Real-Time-Monitoring

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Transform Your Business with a Software ERP System
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Understanding Forklifts - TECH EHS Solution
VVF-Customer-Presentation2025-Ver1.9.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
2025 Textile ERP Trends: SAP, Odoo & Oracle
Essential Infomation Tech presentation.pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Transform Your Business with a Software ERP System
How to Migrate SBCGlobal Email to Yahoo Easily
Wondershare Filmora 15 Crack With Activation Key [2025
Operating system designcfffgfgggggggvggggggggg
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

Why and what is go