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
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Keep packages backwards compatible
FOSDEM 2017 talk on keeping Go packages backwards compatible
Ernesto Jiménez
February 05, 2017
More Decks by Ernesto Jiménez
See All by Ernesto Jiménez
From Zero to 400 webhooks/second in 24 hours
ernesto_jimenez
0
130
Learning Go - Build your first Slack app using Go and App Engine
ernesto_jimenez
0
180
Inception. Go programs that generate Go code
ernesto_jimenez
3
470
Other Decks in Programming
See All in Programming
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.9k
AIの中の人になってみる
htkym
0
160
不幸な GC
chencmd
0
880
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.7k
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
810
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
280
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
980
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
120
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
110
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
130
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
570
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
550
Being A Developer After 40
akosma
91
590k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
270
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
Designing for Timeless Needs
cassininazir
1
470
GraphQLとの向き合い方2022年版
quramy
50
15k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
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]