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
CSC307 Lecture 05
javiergs
PRO
0
500
Data-Centric Kaggle
isax1015
2
770
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
130
「ブロックテーマでは再現できない」は本当か?
inc2734
0
990
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
CSC307 Lecture 02
javiergs
PRO
1
780
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
230
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
高速開発のためのコード整理術
sutetotanuki
1
400
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
190
AgentCoreとHuman in the Loop
har1101
5
230
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
First, design no harm
axbom
PRO
2
1.1k
[SF Ruby Conf 2025] Rails X
palkan
1
750
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Testing 201, or: Great Expectations
jmmastey
46
8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
65
Code Review Best Practice
trishagee
74
20k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
94
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]