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
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
120
品質ワークショップをやってみた
nealle
0
910
Dive into Triton Internals
appleparan
0
420
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
220
Pythonに漸進的に型をつける
nealle
1
150
ネストしたdata classの面倒な更新にさようなら!Lensを作って理解するArrowのOpticsの世界
shiita0903
1
240
スキーマ駆動で、Zod OpenAPI Honoによる、API開発するために、Hono Takibiというライブラリを作っている
nakita628
0
330
Software Architecture
hschwentner
6
2.4k
Migration to Signals, Resource API, and NgRx Signal Store
manfredsteyer
PRO
0
140
ビルドプロセスをデバッグしよう!
yt8492
0
220
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
4
18k
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
250
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
36
7k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
950
Making the Leap to Tech Lead
cromwellryan
135
9.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
BBQ
matthewcrist
89
9.9k
Fireside Chat
paigeccino
41
3.7k
Visualization
eitanlees
150
16k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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]