Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Keep packages backwards compatible
Search
Ernesto Jiménez
February 05, 2017
Programming
0
140
Keep packages backwards compatible
FOSDEM 2017 talk on keeping Go packages backwards compatible
Ernesto Jiménez
February 05, 2017
Tweet
Share
More Decks by Ernesto Jiménez
See All by Ernesto Jiménez
From Zero to 400 webhooks/second in 24 hours
ernesto_jimenez
0
110
Learning Go - Build your first Slack app using Go and App Engine
ernesto_jimenez
0
170
Inception. Go programs that generate Go code
ernesto_jimenez
3
450
Other Decks in Programming
See All in Programming
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
970
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
Pythonスレッドとは結局何なのか? CPython実装から見るNoGIL時代の変化
curekoshimizu
5
1.7k
技術的負債の正体を知って向き合う / Facing Technical Debt
irof
0
150
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
550
Le côté obscur des IA génératives
pascallemerrer
0
140
2分台で1500examples完走!爆速CIを支える環境構築術 - Kaigi on Rails 2025
falcon8823
3
3.5k
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
490
Serena MCPのすすめ
wadakatu
4
960
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
220
ポスターセッション: 「まっすぐ行って、右!」って言ってラズパイカーを動かしたい 〜生成AI × Raspberry Pi Pico × Gradioの試作メモ〜
komofr
0
1.2k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.4k
A Modern Web Designer's Workflow
chriscoyier
697
190k
KATA
mclloyd
32
15k
Building an army of robots
kneath
306
46k
Designing for humans not robots
tammielis
254
26k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
Side Projects
sachag
455
43k
Speed Design
sergeychernyshev
32
1.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
860
GitHub's CSS Performance
jonrohan
1032
470k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Transcript
keep packages backwards compatible
some tips
Small APIs commit to everything you export
Export fewer interfaces
package example type Service interface { Process() } func New()
Service { return &service{} }
package example type Service interface { Process() NewMethod() // ⚡
} func New() Service { return &service{} }
Receive interfaces Return structs
package example type Service struct { // ... } func
New() *Service { return &Service{} }
Export your input interfaces
package example func Process(in input) error { // ... }
// ⚠ type input interface { // ... }
None
// Input exported for documentation type Input interface { //
... } func Process(in Input) error { // ... }
Keeping interfaces to yourself
package testing type TB interface { Error(args ...interface{}) Fail() //
... // contains filtered or unexported methods }
package testing type TB interface { Error(args ...interface{}) Fail() //
... // A private method to prevent users implementing // interface and so future additions to it will // violate Go 1 compatibility. private() }
Nice optional params
cr, _ := crawler.New() cr.Crawl("http://godoc.org", process)
cr, _ := crawler.New( crawler.WithAllowedHosts("godoc.org"), ) cr.Crawl("http://godoc.org", process)
cr, _ := crawler.New( crawler.WithAllowedHosts("godoc.org"), crawler.WithMaxDepth(4), ) cr.Crawl("http://godoc.org", process)
func New(opts ...Option) (*Simple, error) type Option func(*options) error type
options struct
// WithMaxDepth sets the max depth of the crawl func
WithMaxDepth(depth int) Option { return func(opts *options) error { if depth < 0 { return fmt.Errorf("invalid depth: %d", depth) } opts.maxDepth = depth return nil } }
None
Be backwards compatible!
twitter.com/ernesto_jimenez
[email protected]