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 06
javiergs
PRO
0
680
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
110
CSC307 Lecture 07
javiergs
PRO
0
540
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
120
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
190
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
640
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
220
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
12
6.4k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
150
Data-Centric Kaggle
isax1015
2
760
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
120
So, you think you're a good person
axbom
PRO
2
1.9k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
59
42k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
180
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Being A Developer After 40
akosma
91
590k
The browser strikes back
jonoalderson
0
360
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Why Our Code Smells
bkeepers
PRO
340
58k
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]