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

Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guideN Masahiro
 
VCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするVCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするKengo HAMASAKI
 
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)Sneha Inguva
 
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.0Zabbix
 
Weave Networking on Docker
Weave Networking on DockerWeave Networking on Docker
Weave Networking on DockerStylight
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet ShieldTinker
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganetikawamuray
 
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 daemonGeert Van Pamel
 
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 2016Jian-Hong Pan
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with phpElizabeth Smith
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVSsnrism
 
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 compilerVladimir Sedach
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filterGiovanni Bechis
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgKenny (netman)
 
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 DataBalaBit
 

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

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 CarsLinkedIn
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking featuresstrikr .
 
Europe ai scaleups report 2016
Europe ai scaleups report 2016Europe ai scaleups report 2016
Europe ai scaleups report 2016Omar Mohout
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Gostrikr .
 
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 #MNSearchCasey Markee, MBA
 
UDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportUDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportMindShift Interactive
 
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 SecurityLivingston International
 
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 WINNERS-at-WORK Pty Ltd
 
pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311Tairo Hosokai
 
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 MediaMarie Ennis-O'Connor
 
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 ...Jordi Varela
 
WAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようWAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようNozomi Sawada
 
Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Toru Fujimoto
 
確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果Kiyoshi Ogawa
 
Looking Beyond the SEO Plugin
Looking Beyond the SEO PluginLooking Beyond the SEO Plugin
Looking Beyond the SEO PluginRebecca Gill
 

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 Javaelliando dias
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
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 GoRodolfo Carvalho
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitManfred Touron
 
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 easeKAI CHU CHUNG
 
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 Gotdc-globalcode
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web AppsMark
 
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 wayOleg Podsechin
 
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 ライブコーディングscalaconfjp
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Ngoc Dao
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)Ajay Khatri
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and MonoidsHugo Gävert
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Asher Martin
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 

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

Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmonyelliciumsolutionspun
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdfMeon Technology
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Neo4j
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxPrakarsh -
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9Jürgen Gutsch
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfBrain Inventory
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntelliSource Technologies
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Projectwajrcs
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 

Recently uploaded (20)

Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdf
 
Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptx
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9
 
Sustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire ThornewillSustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire Thornewill
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdf
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptx
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 

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) }