SlideShare a Scribd company logo
1 of 27
Download to read offline
What is new in
Go 1.8
@huazhihao
Agenda
● Language
● Runtime
● Standard Library
● Tool Chain
Language
● Conversion ignoring struct tags
● Alias declaration
Conversion ignoring struct tags
type X struct {
Name string
Num int
}
var Y struct {
Name string `json:"name"`
Num int `json:"num"`
}
Alias declaration
type Foo => pkg.Bar
An alternate syntax in 1.9 ?
AliasSpec = identifier "=>" PackageName "." identifier .
const C => pkg.C
type T => pkg.T
var V => pkg.V
func F => pkg.F
Runtime
● gc pause (< 1ms)
● build (15% speedup)
● defer (10%-35% speedup)
● cgo (45% speedup)
GC pause down to 1ms
1.6 40ms
1.5 300ms
STW Stack Rescanning
Replaced by a hybrid write barrier combines:
● a Yuasa-style deletion write barrier
● a Dijkstra-style insertion write barrier
An improved implementation of write barrier merged in dev branch reduces the gc
pause reliably to 100µs(GOMAXPROCS=12).
ARM SSA Support
SSA(Static single assignment) form is widely used in modern compilers
Go didn’t have an SSA representation in its internals because it's derived from an
old C compiler which predated SSA.
SSA was introduced into the x86/64 platforms in Go 1.7 and immediately made
● 5–35% speedup
● 20–30% reduction in binary size
Static single assignment form in 1 minute
y = 1
y = 2
x = y
↓
y1 = 1
y2 = 2
x1 = y2
Benefits
● constant propagation
● value range propagation
● sparse conditional constant propagation
● dead code elimination
● global value numbering
● partial redundancy elimination
● strength reduction
● register allocation
Compile speed comparison
Faster defer
(µs)
Faster cgo
ns/op
Standard Library
● HTTP Graceful Shutdown
● HTTP2 Server Push
● TLS Additions
● SQL Additions
● Inline Slice Sorting
● Import path of context
HTTP Graceful Shutdown
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
srv := &http.Server{Addr: ":8080", Handler: http.DefaultServeMux}
go func() {
<-quit
log.Println("Shutting down server...")
if err := srv.Shutdown(context.Background()); err != nil {
log.Fatalf("could not shutdown: %v", err)
}
}()
HTTP2 Server Push
http.Handle("/static", http.FileServer(http.Dir("./static")))
http.HandleFunc("/index.html",
func(w http.ResponseWriter, r *http.Request) {
if p, ok := w.(http.Pusher); ok {
p.Push("/static/style.css", nil)
p.Push("/static/image.png", nil)
}
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(`
<link href="/static/style.css" rel="stylesheet" />
<img src="/static/image.png" />`))
})
http.ListenAndServeTLS(":4430", "cert.pem", "key.pem", nil)
Stream Frame
/static/style.css PUSH_PROMISE
/static/image.png PUSH_PROMISE
/index.html HEADERS
/index.html DATA
/static/style.css HEADERS
/static/style.css DATA
/static/image.png HEADERS
/static/image.png DATA
TLS Additions
● Support for ChaCha20-Poly1305 based cipher suites
● CipherSuites automatically selected based on hardware support availability if
not specified
● More flexible config APIs
SQL Additions
● Cancelable queries
ctx, cancel := context.WithCancel(context.Background())
● Visible database types
type RowsColumnTypeDatabaseTypeName interface {
Rows
ColumnTypeDatabaseTypeName(index int) string
}
● Multiple result sets
rows.NextResultSet()
● Ping can hit server
Conn.Ping() or Conn.PingContext(ctx)
● Named parameters
sql.Named("Name", value)
● Transaction isolation
BeginTx(ctx context.Context, opts *TxOptions)
Inline Slice Sorting
sort.Sort:
type ByKey []Item
func (items ByKey) Len() int { …
//Len implementation
}
func (items ByKey) Swap(i, j int) { ...
//Swap implementation
}
func (items ByKey) Less(i, j int) bool { …
//Less implementation
}
sort.Sort(ByKey(items))
sort.Slice:
sort.Slice(items, func(i, j int) bool {
//Less implementation
})
Sorting Benchmark
Import path of context
-import "golang.org/x/net/context"
+import "context"
Fix the import by running below on your code base:
# dry run
go tool fix -diff -force=context PATH
# overwrite
go tool fix -force=context PATH
Tool Chain
● Plugins (Shared libraries)
● Default GOPATH
● go bug
● Smarter go vet
Plugins (Shared libraries)
plugin.go:
package shared
import "fmt"
var V int
func F() { fmt.Printf("Hello, number %dn", V) }
main.go:
package main
import "plugin"
func main() {
p, err := plugin.Open("plugin.so")
v, err := p.Lookup("V")
f, err := p.Lookup("F")
*v.(*int) = 7
f.(func())() // prints "Hello, number 7"
}
plugin.so:
$ go build -buildmode=plugin plugin.go
Default GOPATH
When GOPATH is not defined, the runtime will use:
● $HOME/go on Unix
● %USERPROFILE%go on Windows
go bug
The easiest way to file a new issue:
Run `go bug`
Your browser will open https://github.com/golang/go/issues/new with system
details prefilled
Smarter go vet
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
res, err := http.Get("https://golang.org")
defer res.Body.Close()
if err != nil {
log.Fatal(err)
}
io.Copy(os.Stdout, res.Body)
}
Thank you
i@huazhihao.com

More Related Content

What's hot

Weave Networking on Docker
Weave Networking on DockerWeave Networking on Docker
Weave Networking on Docker
Stylight
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big DataSCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
BalaBit
 

What's hot (20)

Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guide
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
VCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするVCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイする
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)
 
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
 
Weave Networking on Docker
Weave Networking on DockerWeave Networking on Docker
Weave Networking on Docker
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet Shield
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Fluentd meetup
Fluentd meetupFluentd meetup
Fluentd meetup
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemon
 
Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVS
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Fluentd introduction at ipros
Fluentd introduction at iprosFluentd introduction at ipros
Fluentd introduction at ipros
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filter
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big DataSCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
 

Viewers also liked

Viewers also liked (18)

Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking features
 
Europe ai scaleups report 2016
Europe ai scaleups report 2016Europe ai scaleups report 2016
Europe ai scaleups report 2016
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Go
 
File Collaboration, at its best
File Collaboration, at its bestFile Collaboration, at its best
File Collaboration, at its best
 
BLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearchBLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearch
 
UDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportUDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign Report
 
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain SecurityCustoms-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
 
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
 
pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311
 
Editorial Honors for Professional Builder
Editorial Honors for Professional BuilderEditorial Honors for Professional Builder
Editorial Honors for Professional Builder
 
15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social Media15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social Media
 
140 years of gender equality
140 years of gender equality140 years of gender equality
140 years of gender equality
 
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
 
WAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようWAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しよう
 
Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Games for Health分野の研究開発事例
Games for Health分野の研究開発事例
 
確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果
 
Looking Beyond the SEO Plugin
Looking Beyond the SEO PluginLooking Beyond the SEO Plugin
Looking Beyond the SEO Plugin
 

Similar to What is new in Go 1.8

REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
elliando dias
 

Similar to What is new in Go 1.8 (20)

REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-Kit
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
cq_cxf_integration
cq_cxf_integrationcq_cxf_integration
cq_cxf_integration
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Azure F#unctions
Azure F#unctionsAzure F#unctions
Azure F#unctions
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 

What is new in Go 1.8

  • 1. What is new in Go 1.8 @huazhihao
  • 2. Agenda ● Language ● Runtime ● Standard Library ● Tool Chain
  • 3. Language ● Conversion ignoring struct tags ● Alias declaration
  • 4. Conversion ignoring struct tags type X struct { Name string Num int } var Y struct { Name string `json:"name"` Num int `json:"num"` }
  • 5. Alias declaration type Foo => pkg.Bar An alternate syntax in 1.9 ? AliasSpec = identifier "=>" PackageName "." identifier . const C => pkg.C type T => pkg.T var V => pkg.V func F => pkg.F
  • 6. Runtime ● gc pause (< 1ms) ● build (15% speedup) ● defer (10%-35% speedup) ● cgo (45% speedup)
  • 7. GC pause down to 1ms 1.6 40ms 1.5 300ms
  • 8. STW Stack Rescanning Replaced by a hybrid write barrier combines: ● a Yuasa-style deletion write barrier ● a Dijkstra-style insertion write barrier An improved implementation of write barrier merged in dev branch reduces the gc pause reliably to 100µs(GOMAXPROCS=12).
  • 9. ARM SSA Support SSA(Static single assignment) form is widely used in modern compilers Go didn’t have an SSA representation in its internals because it's derived from an old C compiler which predated SSA. SSA was introduced into the x86/64 platforms in Go 1.7 and immediately made ● 5–35% speedup ● 20–30% reduction in binary size
  • 10. Static single assignment form in 1 minute y = 1 y = 2 x = y ↓ y1 = 1 y2 = 2 x1 = y2 Benefits ● constant propagation ● value range propagation ● sparse conditional constant propagation ● dead code elimination ● global value numbering ● partial redundancy elimination ● strength reduction ● register allocation
  • 14. Standard Library ● HTTP Graceful Shutdown ● HTTP2 Server Push ● TLS Additions ● SQL Additions ● Inline Slice Sorting ● Import path of context
  • 15. HTTP Graceful Shutdown quit := make(chan os.Signal) signal.Notify(quit, os.Interrupt) srv := &http.Server{Addr: ":8080", Handler: http.DefaultServeMux} go func() { <-quit log.Println("Shutting down server...") if err := srv.Shutdown(context.Background()); err != nil { log.Fatalf("could not shutdown: %v", err) } }()
  • 16. HTTP2 Server Push http.Handle("/static", http.FileServer(http.Dir("./static"))) http.HandleFunc("/index.html", func(w http.ResponseWriter, r *http.Request) { if p, ok := w.(http.Pusher); ok { p.Push("/static/style.css", nil) p.Push("/static/image.png", nil) } w.Header().Set("Content-Type", "text/html") w.Write([]byte(` <link href="/static/style.css" rel="stylesheet" /> <img src="/static/image.png" />`)) }) http.ListenAndServeTLS(":4430", "cert.pem", "key.pem", nil) Stream Frame /static/style.css PUSH_PROMISE /static/image.png PUSH_PROMISE /index.html HEADERS /index.html DATA /static/style.css HEADERS /static/style.css DATA /static/image.png HEADERS /static/image.png DATA
  • 17. TLS Additions ● Support for ChaCha20-Poly1305 based cipher suites ● CipherSuites automatically selected based on hardware support availability if not specified ● More flexible config APIs
  • 18. SQL Additions ● Cancelable queries ctx, cancel := context.WithCancel(context.Background()) ● Visible database types type RowsColumnTypeDatabaseTypeName interface { Rows ColumnTypeDatabaseTypeName(index int) string } ● Multiple result sets rows.NextResultSet() ● Ping can hit server Conn.Ping() or Conn.PingContext(ctx) ● Named parameters sql.Named("Name", value) ● Transaction isolation BeginTx(ctx context.Context, opts *TxOptions)
  • 19. Inline Slice Sorting sort.Sort: type ByKey []Item func (items ByKey) Len() int { … //Len implementation } func (items ByKey) Swap(i, j int) { ... //Swap implementation } func (items ByKey) Less(i, j int) bool { … //Less implementation } sort.Sort(ByKey(items)) sort.Slice: sort.Slice(items, func(i, j int) bool { //Less implementation })
  • 21. Import path of context -import "golang.org/x/net/context" +import "context" Fix the import by running below on your code base: # dry run go tool fix -diff -force=context PATH # overwrite go tool fix -force=context PATH
  • 22. Tool Chain ● Plugins (Shared libraries) ● Default GOPATH ● go bug ● Smarter go vet
  • 23. Plugins (Shared libraries) plugin.go: package shared import "fmt" var V int func F() { fmt.Printf("Hello, number %dn", V) } main.go: package main import "plugin" func main() { p, err := plugin.Open("plugin.so") v, err := p.Lookup("V") f, err := p.Lookup("F") *v.(*int) = 7 f.(func())() // prints "Hello, number 7" } plugin.so: $ go build -buildmode=plugin plugin.go
  • 24. Default GOPATH When GOPATH is not defined, the runtime will use: ● $HOME/go on Unix ● %USERPROFILE%go on Windows
  • 25. go bug The easiest way to file a new issue: Run `go bug` Your browser will open https://github.com/golang/go/issues/new with system details prefilled
  • 26. Smarter go vet package main import ( "io" "log" "net/http" "os" ) func main() { res, err := http.Get("https://golang.org") defer res.Body.Close() if err != nil { log.Fatal(err) } io.Copy(os.Stdout, res.Body) }