SlideShare a Scribd company logo
Highlights of Go 1.1
May 29, 2013

John Graham-Cumming

www.cloudflare.com!
Method Values
•  Function value bound to specific receiver
type Prefixer struct {!
prefix string!
}!
!
func (p Prefixer) Add(s string) string {!
return p.prefix + ": " + s!
}!
!
func main() {!
hawaii := Prefixer{"Aloha”}!
fmt.Printf("%sn", hawaii.Add("Welcome to Honolulu"))!
!
adder := hawaii.Add!
fmt.Printf("%sn", adder("Welcome to Honolulu"))!
}!

www.cloudflare.com!
Change to return handling
•  return statement not needed at end of functions if

function termination is unambiguous

func even() int {!
for {!
if i := rand.Intn(100); i%2 == 0 {!
return i!
}!
}!
}!

•  Worth reading the specification on ‘terminating

statements’
•  http://golang.org/ref/spec#Terminating_statements

www.cloudflare.com!
bufio.Scanner
•  Simple, fast type for doing command tasks like reading

os.Stdin line by line, or reading word by word from a
file
scanner := bufio.NewScanner(os.Stdin)!
!
for scanner.Scan() {!
fmt.Println(scanner.Text()!
}!
!
if err := scanner.Err(); err != nil {!
// Handle error!
}!

•  Built in scanners for lines, words, characters and runes
•  Can provide a custom scanner function

www.cloudflare.com!
Size of int
•  On 64-bit platforms int and uint are now 64 bits
•  Elsewhere they are 32-bits.

•  Couple of consequences:
•  If your code was relying on them being 32-bits then you may have
trouble
x := ^uint32(0)
i := int(x)
!
!
fmt.Println(i)!

!// x is 0xffffffff!
!// i is -1 on 32-bit systems, !
!// 0xffffffff on 64-bit!


•  Slice indexes are ints which means they can have 2 billion
members



www.cloudflare.com!
Heap size and Platforms
•  On 64-bit machines heap can now be tens of GB
•  No change on 32-bit
•  If you were running off tip in recent months you already

had massive heaps
•  Experimental support for: linux/arm, freebsd/arm,

netbsd/386, amd64 and arm, openbsd/386 and
amd64

www.cloudflare.com!
Nanosecond timing




•  FreeBSD, Linux, NetBSD, OpenBSD, OS X time package

has nanosecond precision
•  time.Round and time.Truncate to round up/down to
nearest multiples of any time.Duration
t, _ := time.Parse("2006 Jan 02 15:04:05", "2012 Dec
07 12:15:30.918273645")!
trunc := []time.Duration{!
time.Nanosecond, time.Microsecond,!
time.Millisecond, time.Second,!
2 * time.Second, time.Minute,!
10 * time.Minute, time.Hour, !
}!
for _, d := range trunc {!
fmt.Printf("t.Truncate(%6s) = %sn", d,
t.Truncate(d).Format("15:04:05.999999999"))!
}!
www.cloudflare.com!
Performance
•  Claimed 30 to 40% performance increase over Go 1.0.3


•  Best analysis by Dave Cheney:
•  http://dave.cheney.net/2013/05/21/go-11-performance-

improvements
•  http://dave.cheney.net/2013/05/25/go-11-performanceimprovements-part-2
•  http://dave.cheney.net/2013/05/28/go-11-performanceimprovements-part-3


•  Dave’s summary: 30-40% performance increase is real

www.cloudflare.com!
Performance Highlights
•  Code generation improvements across all three gc

compilers
•  Improvements to inlining
•  Reduction in stack usage
•  Parallel garbage collector. 
•  More precise garbage collection, which reduces the size
of the heap, leading to lower GC pause times.
•  New runtime scheduler; tight integration of the scheduler
with the net package
•  Parts of the runtime and standard library have been
rewritten in assembly to take advantage of specific bulk
move or crypto instructions.
www.cloudflare.com!
Race Detector




•  http://golang.org/doc/articles/race_detector.html
•  Detects concurrent access by two goroutines to the

same variable where one access is write
func main() {!
c := make(chan bool)!
m := make(map[string]string)!
!
go func() {!
m["1"] = "a" // First conflicting access.!
c <- true!
}()!
!
m["2"] = "b" // Second conflicting access.!
<-c!
}!

•  go build –race example.go
www.cloudflare.com!
Full release notes
•  http://golang.org/doc/go1.1


•  Go 1.1 is backwards compatible with Go 1.0.3

•  Go 1.2 targeted for December 1


www.cloudflare.com!

More Related Content

PDF
Highlights of Go 1.1
PDF
Concurrency in Golang
PDF
Go concurrency
PDF
Some Tricks in Using Terminal - KienDT
PDF
user2015 keynote talk
PPTX
15 map reduce on azure
PDF
Go on!
PPTX
Improving go-git performance
Highlights of Go 1.1
Concurrency in Golang
Go concurrency
Some Tricks in Using Terminal - KienDT
user2015 keynote talk
15 map reduce on azure
Go on!
Improving go-git performance

What's hot (19)

PPTX
Class 24: Imperative Programming
PDF
Python code for the determination of equivalent horizontal and vertical hydra...
PDF
Actor Based Asyncronous IO in Akka
PDF
Yampa AFRP Introduction
PPT
Jan 2012 HUG: RHadoop
PDF
PDF
GoLang & GoatCore
PPT
Algorithm cup 2010
PDF
Internet of dusty things
PDF
Fast and cost effective geospatial analysis pipeline with AWS lambda
PDF
Rails Scripts
PDF
Basicsof c make and git for a hello qt application
PDF
Libtcc and gwan
PDF
The async/await concurrency pattern in Golang
PDF
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
PPTX
Implementation of Bitcoin Miner on SW and HW
PDF
Building a DSL with GraalVM (VoxxedDays Luxembourg)
PDF
Scaling FastAGI Applications with Go
PDF
SICP勉強会について
Class 24: Imperative Programming
Python code for the determination of equivalent horizontal and vertical hydra...
Actor Based Asyncronous IO in Akka
Yampa AFRP Introduction
Jan 2012 HUG: RHadoop
GoLang & GoatCore
Algorithm cup 2010
Internet of dusty things
Fast and cost effective geospatial analysis pipeline with AWS lambda
Rails Scripts
Basicsof c make and git for a hello qt application
Libtcc and gwan
The async/await concurrency pattern in Golang
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
Implementation of Bitcoin Miner on SW and HW
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Scaling FastAGI Applications with Go
SICP勉強会について
Ad

Viewers also liked (20)

ODP
Dualacy uni chapter one
PPT
La luna y la vaca
PDF
Pregnancy six
DOC
Bio Lab Paper
ODP
Winter 1 cooke
ODP
Winter 1 vega
PPTX
Мобильная версия E96. Взгляд менеджера и взгляд разработчика (Версия для #ose...
PDF
Spring 3 Cooke
ODP
Summer 2 cooke
PDF
Chapter 8
PPTX
CMC Teacher Education SIG Presentation; Tsouris
PPTX
CMC Teacher Education SIG Presentation; Lomicka
PDF
Spring 3 Lillard
PPTX
buona pasqua
PPT
CMC Teacher Education SIG Presentation; Guichon
PDF
Smith, lit poems 1
PPT
CMC Teacher Education SIG Presentation; Masats & Ambròs
ODP
Summer 2 vega
PDF
Pregnancy five
PPSX
Peoplepro Management Services Pvt. Ltd.
Dualacy uni chapter one
La luna y la vaca
Pregnancy six
Bio Lab Paper
Winter 1 cooke
Winter 1 vega
Мобильная версия E96. Взгляд менеджера и взгляд разработчика (Версия для #ose...
Spring 3 Cooke
Summer 2 cooke
Chapter 8
CMC Teacher Education SIG Presentation; Tsouris
CMC Teacher Education SIG Presentation; Lomicka
Spring 3 Lillard
buona pasqua
CMC Teacher Education SIG Presentation; Guichon
Smith, lit poems 1
CMC Teacher Education SIG Presentation; Masats & Ambròs
Summer 2 vega
Pregnancy five
Peoplepro Management Services Pvt. Ltd.
Ad

Similar to Highlights of Go 1.1 (20)

PPTX
The GO Language : From Beginners to Gophers
PDF
Mender.io | Develop embedded applications faster | Comparing C and Golang
PDF
LCA2014 - Introduction to Go
PDF
Introduction to go language programming
PDF
Go serving: Building server app with go
PDF
Concurrent Programming in Go basics and programming
PDF
Go for Rubyists
PDF
Go, the one language to learn in 2014
PDF
JDD2014: GO! The one language you have to try in 2014 - Andrzej Grzesik
PDF
An Introduction to Go
PDF
Golang and Eco-System Introduction / Overview
PDF
I don't know what I'm Doing: A newbie guide for Golang for DevOps
PDF
Let's Go-lang
PPTX
golang_getting_started.pptx
PPTX
Go. Why it goes
PDF
Inroduction to golang
PDF
Happy Go Programming Part 1
PDF
Go 1.10 Release Party - PDX Go
ODP
Ready to go
PDF
The Go features I can't live without, 2nd round
The GO Language : From Beginners to Gophers
Mender.io | Develop embedded applications faster | Comparing C and Golang
LCA2014 - Introduction to Go
Introduction to go language programming
Go serving: Building server app with go
Concurrent Programming in Go basics and programming
Go for Rubyists
Go, the one language to learn in 2014
JDD2014: GO! The one language you have to try in 2014 - Andrzej Grzesik
An Introduction to Go
Golang and Eco-System Introduction / Overview
I don't know what I'm Doing: A newbie guide for Golang for DevOps
Let's Go-lang
golang_getting_started.pptx
Go. Why it goes
Inroduction to golang
Happy Go Programming Part 1
Go 1.10 Release Party - PDX Go
Ready to go
The Go features I can't live without, 2nd round

More from Cloudflare (20)

PDF
Succeeding with Secure Access Service Edge (SASE)
PPTX
Close your security gaps and get 100% of your traffic protected with Cloudflare
PPTX
Why you should replace your d do s hardware appliance
PPTX
Don't Let Bots Ruin Your Holiday Business - Snackable Webinar
PPTX
Why Zero Trust Architecture Will Become the New Normal in 2021
PPTX
HARTMANN and Cloudflare Learn how healthcare providers can build resilient in...
PPTX
Zero trust for everybody: 3 ways to get there fast
PPTX
LendingTree and Cloudflare: Ensuring zero trade-off between security and cust...
PPTX
Network Transformation: What it is, and how it’s helping companies stay secur...
PPTX
Scaling service provider business with DDoS-mitigation-as-a-service
PPTX
Application layer attack trends through the lens of Cloudflare data
PPTX
Recent DDoS attack trends, and how you should respond
PPTX
Cybersecurity 2020 threat landscape and its implications (AMER)
PPTX
Strengthening security posture for modern-age SaaS providers
PPTX
Kentik and Cloudflare Partner to Mitigate Advanced DDoS Attacks
PDF
Stopping DDoS Attacks in North America
PPTX
It’s 9AM... Do you know what’s happening on your network?
PPTX
Cyber security fundamentals (simplified chinese)
PPTX
Bring speed and security to the intranet with cloudflare for teams
PPTX
Accelerate your digital transformation
Succeeding with Secure Access Service Edge (SASE)
Close your security gaps and get 100% of your traffic protected with Cloudflare
Why you should replace your d do s hardware appliance
Don't Let Bots Ruin Your Holiday Business - Snackable Webinar
Why Zero Trust Architecture Will Become the New Normal in 2021
HARTMANN and Cloudflare Learn how healthcare providers can build resilient in...
Zero trust for everybody: 3 ways to get there fast
LendingTree and Cloudflare: Ensuring zero trade-off between security and cust...
Network Transformation: What it is, and how it’s helping companies stay secur...
Scaling service provider business with DDoS-mitigation-as-a-service
Application layer attack trends through the lens of Cloudflare data
Recent DDoS attack trends, and how you should respond
Cybersecurity 2020 threat landscape and its implications (AMER)
Strengthening security posture for modern-age SaaS providers
Kentik and Cloudflare Partner to Mitigate Advanced DDoS Attacks
Stopping DDoS Attacks in North America
It’s 9AM... Do you know what’s happening on your network?
Cyber security fundamentals (simplified chinese)
Bring speed and security to the intranet with cloudflare for teams
Accelerate your digital transformation

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
Teaching material agriculture food technology
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
cuic standard and advanced reporting.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Teaching material agriculture food technology
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Dropbox Q2 2025 Financial Results & Investor Presentation
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Electronic commerce courselecture one. Pdf
Big Data Technologies - Introduction.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
cuic standard and advanced reporting.pdf

Highlights of Go 1.1

  • 1. Highlights of Go 1.1 May 29, 2013 John Graham-Cumming www.cloudflare.com!
  • 2. Method Values •  Function value bound to specific receiver type Prefixer struct {! prefix string! }! ! func (p Prefixer) Add(s string) string {! return p.prefix + ": " + s! }! ! func main() {! hawaii := Prefixer{"Aloha”}! fmt.Printf("%sn", hawaii.Add("Welcome to Honolulu"))! ! adder := hawaii.Add! fmt.Printf("%sn", adder("Welcome to Honolulu"))! }! www.cloudflare.com!
  • 3. Change to return handling •  return statement not needed at end of functions if function termination is unambiguous func even() int {! for {! if i := rand.Intn(100); i%2 == 0 {! return i! }! }! }! •  Worth reading the specification on ‘terminating statements’ •  http://golang.org/ref/spec#Terminating_statements www.cloudflare.com!
  • 4. bufio.Scanner •  Simple, fast type for doing command tasks like reading os.Stdin line by line, or reading word by word from a file scanner := bufio.NewScanner(os.Stdin)! ! for scanner.Scan() {! fmt.Println(scanner.Text()! }! ! if err := scanner.Err(); err != nil {! // Handle error! }! •  Built in scanners for lines, words, characters and runes •  Can provide a custom scanner function www.cloudflare.com!
  • 5. Size of int •  On 64-bit platforms int and uint are now 64 bits •  Elsewhere they are 32-bits. •  Couple of consequences: •  If your code was relying on them being 32-bits then you may have trouble x := ^uint32(0) i := int(x) ! ! fmt.Println(i)! !// x is 0xffffffff! !// i is -1 on 32-bit systems, ! !// 0xffffffff on 64-bit! •  Slice indexes are ints which means they can have 2 billion members www.cloudflare.com!
  • 6. Heap size and Platforms •  On 64-bit machines heap can now be tens of GB •  No change on 32-bit •  If you were running off tip in recent months you already had massive heaps •  Experimental support for: linux/arm, freebsd/arm, netbsd/386, amd64 and arm, openbsd/386 and amd64 www.cloudflare.com!
  • 7. Nanosecond timing •  FreeBSD, Linux, NetBSD, OpenBSD, OS X time package has nanosecond precision •  time.Round and time.Truncate to round up/down to nearest multiples of any time.Duration t, _ := time.Parse("2006 Jan 02 15:04:05", "2012 Dec 07 12:15:30.918273645")! trunc := []time.Duration{! time.Nanosecond, time.Microsecond,! time.Millisecond, time.Second,! 2 * time.Second, time.Minute,! 10 * time.Minute, time.Hour, ! }! for _, d := range trunc {! fmt.Printf("t.Truncate(%6s) = %sn", d, t.Truncate(d).Format("15:04:05.999999999"))! }! www.cloudflare.com!
  • 8. Performance •  Claimed 30 to 40% performance increase over Go 1.0.3 •  Best analysis by Dave Cheney: •  http://dave.cheney.net/2013/05/21/go-11-performance- improvements •  http://dave.cheney.net/2013/05/25/go-11-performanceimprovements-part-2 •  http://dave.cheney.net/2013/05/28/go-11-performanceimprovements-part-3 •  Dave’s summary: 30-40% performance increase is real www.cloudflare.com!
  • 9. Performance Highlights •  Code generation improvements across all three gc compilers •  Improvements to inlining •  Reduction in stack usage •  Parallel garbage collector. •  More precise garbage collection, which reduces the size of the heap, leading to lower GC pause times. •  New runtime scheduler; tight integration of the scheduler with the net package •  Parts of the runtime and standard library have been rewritten in assembly to take advantage of specific bulk move or crypto instructions. www.cloudflare.com!
  • 10. Race Detector •  http://golang.org/doc/articles/race_detector.html •  Detects concurrent access by two goroutines to the same variable where one access is write func main() {! c := make(chan bool)! m := make(map[string]string)! ! go func() {! m["1"] = "a" // First conflicting access.! c <- true! }()! ! m["2"] = "b" // Second conflicting access.! <-c! }! •  go build –race example.go www.cloudflare.com!
  • 11. Full release notes •  http://golang.org/doc/go1.1 •  Go 1.1 is backwards compatible with Go 1.0.3 •  Go 1.2 targeted for December 1 www.cloudflare.com!