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
160
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
120
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
470
Other Decks in Programming
See All in Programming
GitHubCopilotCLIのスラッシュコマンドを自作してみる
htkym
0
100
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
540
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
900
5分で問診!Composer セキュリティ健康診断
codmoninc
0
580
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
430
FDEが実現するAI駆動経営の現在地
gonta
2
200
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
530
えっ!!コードを読まずに開発を!?
hananouchi
0
230
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
630
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
180
関数型プログラミングのメリットって何だろう?
wanko_it
0
190
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
9.3k
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
170
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
For a Future-Friendly Web
brad_frost
183
10k
Mind Mapping
helmedeiros
PRO
1
290
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
310
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.3k
Exploring anti-patterns in Rails
aemeredith
3
450
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
The Cult of Friendly URLs
andyhume
79
7k
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]