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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
460
Other Decks in Programming
See All in Programming
SourceGeneratorのマーカー属性問題について
htkym
0
110
AI巻き込み型コードレビューのススメ
nealle
2
2.5k
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3k
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
4
660
並行開発のためのコードレビュー
miyukiw
2
2.1k
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
310
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
120
CSC307 Lecture 10
javiergs
PRO
1
690
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
100
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
340
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
460
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
4
360
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Optimizing for Happiness
mojombo
378
71k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
310
WENDY [Excerpt]
tessaabrams
9
36k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
180
4 Signs Your Business is Dying
shpigford
187
22k
How STYLIGHT went responsive
nonsquared
100
6k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
200
We Are The Robots
honzajavorek
0
190
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]