SlideShare a Scribd company logo
Go. Why it
goes?
1
About me
Serhii Pichkurov
●6+ years of experience
●Mostly backend
●~ 1 year with Go
2
Agenda
● Go is not C, not Java, not anything
● Gopher
● Rob Pike argument
● Main ideas
● Concurrency model
● Tools
● Issues and gotchas 3
Characteristics
Go (often referred to as golang) is:
4
●Clean procedural language designed
for scalable cloud software
●open source
●statically typed with duck typing
Characteristics
●CSP(communicating sequential processes) as
concurrent model
●with garbage collection
●created at Google in 2007 by Robert
Griesemer(V8), Rob Pike(UNIX, UTF-8), and Ken
Thompson(UNIX, regexp)
5
Characteristics
●compiled
●two compilers: "gc"(many platforms including
smartphones) and “gccgo”(more optimizations,
more processors)
●Linux, OS X, FreeBSD, Windows and more
6
Motivated by Google’s needs:
Why new lang?
7
● No surprises
● Efficiency
● Safety
● Concurrency
● Scalability
● Fast development cycle
● A cute mascot
Who uses Go at Google?
Lots of projects. Thousands of Go programmers. Millions
of lines of Go code.
Public examples:
● Kubernetes
● SPDY proxy for Chrome on mobile devices
● dl.google.com is written in Go
● YouTube Vitess MySQL balancer
8
Who uses Go besides Google?
9
Products written in Go
10
Go use-cases
● Cloud/Networking - routers, proxies, etc
● Distributed services and storages
● Internal infrastructures
● Microservices (with frameworks, like
GoKit)
● Containers and orchestration
● Command-line tools
11
Mascot: the gopher
12
Rob Pike
13
Rob Pike argument
● Go is different
● Go does not try to be like the other
languages
● Go does not compete on features
● As of Go 1, the language is fixed
14
Active Development
15
GC in Go 1.6
16https://talks.golang.org/2016/state-of-go.slide
Everything is passed by
value
17
Go elements
● concrete data types
● functions and methods
● interfaces
● structs
● packages
● concurrency
● good tools, fast builds
All the pieces feel simple in practice
18
Types
●bool
●string
●int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64
●byte //alias for uint8
●rune //alias for int32, Unicode char
●float32 float64
●complex32 complex64
19
var c, python, java bool
20
k := 3
c, python, java := true, false, "no!"
21
func do_something() (string, int) {
return "result", 0
}
first, second := do_something()
Unused variables
or imports —
compilation error
22
Arrays
An array's length is part of its type, so arrays
cannot be resized.
var arr [5]int
arr[4] = 42
23
Slices
A slice, on the other hand, is a dynamically-sized,
flexible view(reference) into the elements of an array
var foo []int
24
Slices
foo := make([]int, 5)
25
foo[3] = 42
foo[4] = 100
Slices
bytes := [5]byte{} // array
var slice = bytes[2:4]
names := []string{"leto", "paul", "teg"}
c := make([]string, len(names))
copy(c, names)
names = append(names,"ioav")
26
Maps
m = make(map[string]int) // declare
m["route"] = 66 // put
i := m["route"] // get
delete(m, "route")
_, ok := m["route"] //check is present
27
Maps
Important to remember: when no value is
assigned to key, zero value is returned
28
for key, value := range m { //iterate
fmt.Println("Key:", key, "Value:", value)
}
commits := map[string]int{ //static population
"gri": 1908,
"adg": 912,
}
29
Maps
Interfaces
Just a set of methods. No data. Simple idea, but more
complex than expected.
type Reader interface {
Read(p []byte) (n int, err error)
}
_, err := reader.Read(p)
30
Structs
type Person struct {
FirstName string
LastName string
}
person := Person{FirstName:"title", LastName:"http:..."}
31
Tags aka annotations
type Person struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
MiddleName string `json:"-"`
}
32
xml:"FirstName"`
xml:"LastName"`
xml:"MiddleName"`
Pointers
A pointer holds the memory address of a variable.
The & operator generates a pointer to its operand:
i := 42
p = &i
The * operator denotes the pointer's underlying value:
fmt.Println(*p) // read i through the pointer p
*p = 21 // set i through the pointer p
33
Receivers
type Server struct {
...
}
34
func (srv *Server) Close() error {
...
}
func (srv Server) Name() string {
...
}
Demo
35
Packages
We can import one or more package, there are three types:
system, local and remote.
System – out of the box. Like http, testing, etc
Local – in your repository, no need to use full path.
Remote – has complete import path pointing to the server.
To import remote package:
import "github.com/nf/wav"
36
Getting dependencies
For remote package use go get to fetch into workspace.
go get github.com/nf/wav
Other operations also done via go CLI tool:
go build
go test
go run
and more
37
38
export GOPATH = $HOME/go_workspace
Concurrency
Based on CSP that was first described in a 1978 paper by
Tony Hoare.
Has three elements:
● coroutines (execution)
● channels (communication)
● select (coordination)
39
“
Don't communicate by
sharing memory, share
memory by communicating
40
Goroutines
Start a goroutine with the go keyword:
go function(args)
Like garbage collection, eliminate considerations from the
programmer's concern:
● no stack size
● no return or completion status
● no mechanism for management
● no "ID"
41
Goroutines
●Goroutines are like lightweight threads.
●Go programs can have hundreds of
thousands of them
●The Go runtime schedules goroutines
onto OS threads
●Blocked goroutines don't use a thread
42
Channels
Channels provide communication between
goroutines.
c := make(chan string)
// goroutine 1
c <- "hello!"
// goroutine 2
s := <-c
fmt.Println(s) // "hello!"
43
Select
A select statement blocks until one of its cases can run, then it
executes that case.
msg := "hi"
select {
case n := <-in:
fmt.Println("received", n)
case out <- msg:
fmt.Println("sent", msg)
}
44
Demo time
45
46
Go and Java have much in common
● C family (imperative, braces)
● Statically typed
● Garbage collected
● Memory safe (nil references,
runtime bounds checks)
47
● Variables are always initialized
(zero/nil/false)
● Methods
● Interfaces
● Type assertions (instanceof)
● Reflection
48
Go and Java have much in common
Go differs from Java in several ways
● Programs compile to machine code. There's no VM.
● Statically linked binaries
● Multiple return
● Error handling
● Bit different GC(no compaction)
49
Go intentionally leaves out many features
● No classes
● No ‘implements’ keyword
● No final
● No exceptions
● No user-defined generics
50
Exceptions go away
● no exceptions by design
● handling with multiple return
● panic!
type error interface {
Error() string
}
51
Errors design
rpm, err := rpm.OpenPackageFile(localPath)
if err != nil {
log.Error("Failed to read RPM headers: %v", err)
return
}
file, err = file.ReadAt(archiveHead, int64(headerEnd))
if err != nil {
log.Error("Invalid archive head head: %v", err)
return
} 52
Tools
53
go get is great,
but we need
more
54
Vendoring
server-one uses the mux package in $GOPATH/src/github.com/gorilla/mux.
server-two uses the mux package in vendor.
$GOPATH
src/
server-one/
main.go (import "github.com/gorilla/mux")
server-two/
main.go (import "github.com/gorilla/mux")
vendor/
github.com/
gorilla/
mux/
...
55
Glide for Package Management
● Semantic Versions and Ranges
● Git, Bzr, Hg, Svn
● Works with Go toolchain
● Leverages vendor directory
● Imports from Godep, GB, GPM, Gom
● Private Repos and Forks
56
Go tools support
●go fmt
●goimports
●go lint or gometalinter
●godoc lookups
●go generate
●many more
●easy to write your own
57
IDE
There's no "Go IDE". Go tools meet you where you are.
●Eclipse
●JetBrains(GoLand)
●Atom
●Emacs
●Vim
●many others
58
My experience
Project that searches for vulnerabilities inside artifacts
●microservices
●RabbitMQ
●MongoDB/PostgreSQL
●REST API
●work with files and archives
●Docker
●34860 lines of code
59
Issues and
gotchas
60
Pointers, pointers to
pointers, more
pointers.
61
Nil pointer is still
there and happens in
runtime
62
No generics
63
“
If you want to do
something expensive —
do it explicitly
64
Missing comma in
multi-line Slice,
Array, and Map
Literals
65
func main() {
x := []int{
1,
2 //error
}
_ = x
}
66
Summary
67
“
I’m impressed about how easy
people can pick it up and start
being productive in a project ,
it’s also very easy to deploy
David Cuadrado, Authy
68
Simple can be expressive
69
Simplicity is complicated but
the clarity is worth the fight
70
Thanks!
71
Q&A
72

More Related Content

PPTX
Go. Why it goes
PDF
10 reasons to be excited about go
PPTX
Go Programming Language (Golang)
PDF
FTD JVM Internals
PDF
Go Lang Tutorial
PPTX
Golang basics for Java developers - Part 1
PDF
Introduction to Go programming language
PDF
How it's made: C++ compilers (GCC)
Go. Why it goes
10 reasons to be excited about go
Go Programming Language (Golang)
FTD JVM Internals
Go Lang Tutorial
Golang basics for Java developers - Part 1
Introduction to Go programming language
How it's made: C++ compilers (GCC)

What's hot (20)

ODP
C Under Linux
PPTX
Mixing C++ & Python II: Pybind11
PDF
Basic c++ 11/14 for python programmers
PPTX
Reproducible Computational Research in R
ODP
Vim and Python
PPTX
Go Language Hands-on Workshop Material
PDF
Take advantage of C++ from Python
PDF
Notes about moving from python to c++ py contw 2020
PPT
GCC compiler
ODP
GCC, GNU compiler collection
PDF
2018 cosup-delete unused python code safely - english
PDF
Practicing Python 3
PDF
Machine Learning on Code - SF meetup
PPTX
PDF
Dive into Pinkoi 2013
PDF
С++ without new and delete
PDF
Introduction to Programming in Go
PDF
Fun with Lambdas: C++14 Style (part 1)
PDF
Open source projects with python
PDF
DConf 2016: Keynote by Walter Bright
C Under Linux
Mixing C++ & Python II: Pybind11
Basic c++ 11/14 for python programmers
Reproducible Computational Research in R
Vim and Python
Go Language Hands-on Workshop Material
Take advantage of C++ from Python
Notes about moving from python to c++ py contw 2020
GCC compiler
GCC, GNU compiler collection
2018 cosup-delete unused python code safely - english
Practicing Python 3
Machine Learning on Code - SF meetup
Dive into Pinkoi 2013
С++ without new and delete
Introduction to Programming in Go
Fun with Lambdas: C++14 Style (part 1)
Open source projects with python
DConf 2016: Keynote by Walter Bright
Ad

Similar to Go. why it goes v2 (20)

PDF
Introduction to Google's Go programming language
PPTX
Ready, set, go! An introduction to the Go programming language
PDF
Introduction to Go
PPT
A First Look at Google's Go Programming Language
PPT
Google's Go Programming Language - Introduction
PDF
Inroduction to golang
PPTX
Introduction to go lang
PPTX
Golang - Overview of Go (golang) Language
PDF
PDF
The GO programming language
PPTX
Golang introduction
PDF
Go for Rubyists
PPTX
The GO Language : From Beginners to Gophers
PDF
Golang
PDF
Getting Started with Go
KEY
Google Go Overview
PPTX
go language- haseeb.pptx
PDF
Let's Go-lang
PDF
Why Go Lang?
PDF
Enterprise 2020
Introduction to Google's Go programming language
Ready, set, go! An introduction to the Go programming language
Introduction to Go
A First Look at Google's Go Programming Language
Google's Go Programming Language - Introduction
Inroduction to golang
Introduction to go lang
Golang - Overview of Go (golang) Language
The GO programming language
Golang introduction
Go for Rubyists
The GO Language : From Beginners to Gophers
Golang
Getting Started with Go
Google Go Overview
go language- haseeb.pptx
Let's Go-lang
Why Go Lang?
Enterprise 2020
Ad

Recently uploaded (20)

PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
System and Network Administraation Chapter 3
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Introduction to Artificial Intelligence
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Strategies for Manufacturing Companies
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Cost to Outsource Software Development in 2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Understanding Forklifts - TECH EHS Solution
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
How to Choose the Right IT Partner for Your Business in Malaysia
Reimagine Home Health with the Power of Agentic AI​
Odoo POS Development Services by CandidRoot Solutions
System and Network Administraation Chapter 3
Upgrade and Innovation Strategies for SAP ERP Customers
Introduction to Artificial Intelligence
PTS Company Brochure 2025 (1).pdf.......
Digital Strategies for Manufacturing Companies
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Navsoft: AI-Powered Business Solutions & Custom Software Development
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Why Generative AI is the Future of Content, Code & Creativity?
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Digital Systems & Binary Numbers (comprehensive )
Cost to Outsource Software Development in 2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Understanding Forklifts - TECH EHS Solution

Go. why it goes v2

  • 2. About me Serhii Pichkurov ●6+ years of experience ●Mostly backend ●~ 1 year with Go 2
  • 3. Agenda ● Go is not C, not Java, not anything ● Gopher ● Rob Pike argument ● Main ideas ● Concurrency model ● Tools ● Issues and gotchas 3
  • 4. Characteristics Go (often referred to as golang) is: 4 ●Clean procedural language designed for scalable cloud software ●open source ●statically typed with duck typing
  • 5. Characteristics ●CSP(communicating sequential processes) as concurrent model ●with garbage collection ●created at Google in 2007 by Robert Griesemer(V8), Rob Pike(UNIX, UTF-8), and Ken Thompson(UNIX, regexp) 5
  • 6. Characteristics ●compiled ●two compilers: "gc"(many platforms including smartphones) and “gccgo”(more optimizations, more processors) ●Linux, OS X, FreeBSD, Windows and more 6
  • 7. Motivated by Google’s needs: Why new lang? 7 ● No surprises ● Efficiency ● Safety ● Concurrency ● Scalability ● Fast development cycle ● A cute mascot
  • 8. Who uses Go at Google? Lots of projects. Thousands of Go programmers. Millions of lines of Go code. Public examples: ● Kubernetes ● SPDY proxy for Chrome on mobile devices ● dl.google.com is written in Go ● YouTube Vitess MySQL balancer 8
  • 9. Who uses Go besides Google? 9
  • 11. Go use-cases ● Cloud/Networking - routers, proxies, etc ● Distributed services and storages ● Internal infrastructures ● Microservices (with frameworks, like GoKit) ● Containers and orchestration ● Command-line tools 11
  • 14. Rob Pike argument ● Go is different ● Go does not try to be like the other languages ● Go does not compete on features ● As of Go 1, the language is fixed 14
  • 16. GC in Go 1.6 16https://talks.golang.org/2016/state-of-go.slide
  • 17. Everything is passed by value 17
  • 18. Go elements ● concrete data types ● functions and methods ● interfaces ● structs ● packages ● concurrency ● good tools, fast builds All the pieces feel simple in practice 18
  • 19. Types ●bool ●string ●int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 ●byte //alias for uint8 ●rune //alias for int32, Unicode char ●float32 float64 ●complex32 complex64 19
  • 20. var c, python, java bool 20 k := 3 c, python, java := true, false, "no!"
  • 21. 21 func do_something() (string, int) { return "result", 0 } first, second := do_something()
  • 22. Unused variables or imports — compilation error 22
  • 23. Arrays An array's length is part of its type, so arrays cannot be resized. var arr [5]int arr[4] = 42 23
  • 24. Slices A slice, on the other hand, is a dynamically-sized, flexible view(reference) into the elements of an array var foo []int 24
  • 25. Slices foo := make([]int, 5) 25 foo[3] = 42 foo[4] = 100
  • 26. Slices bytes := [5]byte{} // array var slice = bytes[2:4] names := []string{"leto", "paul", "teg"} c := make([]string, len(names)) copy(c, names) names = append(names,"ioav") 26
  • 27. Maps m = make(map[string]int) // declare m["route"] = 66 // put i := m["route"] // get delete(m, "route") _, ok := m["route"] //check is present 27
  • 28. Maps Important to remember: when no value is assigned to key, zero value is returned 28
  • 29. for key, value := range m { //iterate fmt.Println("Key:", key, "Value:", value) } commits := map[string]int{ //static population "gri": 1908, "adg": 912, } 29 Maps
  • 30. Interfaces Just a set of methods. No data. Simple idea, but more complex than expected. type Reader interface { Read(p []byte) (n int, err error) } _, err := reader.Read(p) 30
  • 31. Structs type Person struct { FirstName string LastName string } person := Person{FirstName:"title", LastName:"http:..."} 31
  • 32. Tags aka annotations type Person struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` MiddleName string `json:"-"` } 32 xml:"FirstName"` xml:"LastName"` xml:"MiddleName"`
  • 33. Pointers A pointer holds the memory address of a variable. The & operator generates a pointer to its operand: i := 42 p = &i The * operator denotes the pointer's underlying value: fmt.Println(*p) // read i through the pointer p *p = 21 // set i through the pointer p 33
  • 34. Receivers type Server struct { ... } 34 func (srv *Server) Close() error { ... } func (srv Server) Name() string { ... }
  • 36. Packages We can import one or more package, there are three types: system, local and remote. System – out of the box. Like http, testing, etc Local – in your repository, no need to use full path. Remote – has complete import path pointing to the server. To import remote package: import "github.com/nf/wav" 36
  • 37. Getting dependencies For remote package use go get to fetch into workspace. go get github.com/nf/wav Other operations also done via go CLI tool: go build go test go run and more 37
  • 38. 38 export GOPATH = $HOME/go_workspace
  • 39. Concurrency Based on CSP that was first described in a 1978 paper by Tony Hoare. Has three elements: ● coroutines (execution) ● channels (communication) ● select (coordination) 39
  • 40. “ Don't communicate by sharing memory, share memory by communicating 40
  • 41. Goroutines Start a goroutine with the go keyword: go function(args) Like garbage collection, eliminate considerations from the programmer's concern: ● no stack size ● no return or completion status ● no mechanism for management ● no "ID" 41
  • 42. Goroutines ●Goroutines are like lightweight threads. ●Go programs can have hundreds of thousands of them ●The Go runtime schedules goroutines onto OS threads ●Blocked goroutines don't use a thread 42
  • 43. Channels Channels provide communication between goroutines. c := make(chan string) // goroutine 1 c <- "hello!" // goroutine 2 s := <-c fmt.Println(s) // "hello!" 43
  • 44. Select A select statement blocks until one of its cases can run, then it executes that case. msg := "hi" select { case n := <-in: fmt.Println("received", n) case out <- msg: fmt.Println("sent", msg) } 44
  • 46. 46
  • 47. Go and Java have much in common ● C family (imperative, braces) ● Statically typed ● Garbage collected ● Memory safe (nil references, runtime bounds checks) 47
  • 48. ● Variables are always initialized (zero/nil/false) ● Methods ● Interfaces ● Type assertions (instanceof) ● Reflection 48 Go and Java have much in common
  • 49. Go differs from Java in several ways ● Programs compile to machine code. There's no VM. ● Statically linked binaries ● Multiple return ● Error handling ● Bit different GC(no compaction) 49
  • 50. Go intentionally leaves out many features ● No classes ● No ‘implements’ keyword ● No final ● No exceptions ● No user-defined generics 50
  • 51. Exceptions go away ● no exceptions by design ● handling with multiple return ● panic! type error interface { Error() string } 51
  • 52. Errors design rpm, err := rpm.OpenPackageFile(localPath) if err != nil { log.Error("Failed to read RPM headers: %v", err) return } file, err = file.ReadAt(archiveHead, int64(headerEnd)) if err != nil { log.Error("Invalid archive head head: %v", err) return } 52
  • 54. go get is great, but we need more 54
  • 55. Vendoring server-one uses the mux package in $GOPATH/src/github.com/gorilla/mux. server-two uses the mux package in vendor. $GOPATH src/ server-one/ main.go (import "github.com/gorilla/mux") server-two/ main.go (import "github.com/gorilla/mux") vendor/ github.com/ gorilla/ mux/ ... 55
  • 56. Glide for Package Management ● Semantic Versions and Ranges ● Git, Bzr, Hg, Svn ● Works with Go toolchain ● Leverages vendor directory ● Imports from Godep, GB, GPM, Gom ● Private Repos and Forks 56
  • 57. Go tools support ●go fmt ●goimports ●go lint or gometalinter ●godoc lookups ●go generate ●many more ●easy to write your own 57
  • 58. IDE There's no "Go IDE". Go tools meet you where you are. ●Eclipse ●JetBrains(GoLand) ●Atom ●Emacs ●Vim ●many others 58
  • 59. My experience Project that searches for vulnerabilities inside artifacts ●microservices ●RabbitMQ ●MongoDB/PostgreSQL ●REST API ●work with files and archives ●Docker ●34860 lines of code 59
  • 61. Pointers, pointers to pointers, more pointers. 61
  • 62. Nil pointer is still there and happens in runtime 62
  • 64. “ If you want to do something expensive — do it explicitly 64
  • 65. Missing comma in multi-line Slice, Array, and Map Literals 65
  • 66. func main() { x := []int{ 1, 2 //error } _ = x } 66
  • 68. “ I’m impressed about how easy people can pick it up and start being productive in a project , it’s also very easy to deploy David Cuadrado, Authy 68
  • 69. Simple can be expressive 69
  • 70. Simplicity is complicated but the clarity is worth the fight 70