$30 off During Our Annual Pro Sale. View Details »
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
認証・認可の基本を学ぼう前編
kouyuume
0
180
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
180
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
3
1.3k
S3 VectorsとStrands Agentsを利用したAgentic RAGシステムの構築
tosuri13
6
290
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
140
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
140
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
36
23k
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
140
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
230
20 years of Symfony, what's next?
fabpot
2
320
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.4k
FluorTracer / RayTracingCamp11
kugimasa
0
200
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.3k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
A Tale of Four Properties
chriscoyier
162
23k
Thoughts on Productivity
jonyablonski
73
5k
Side Projects
sachag
455
43k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Mobile First: as difficult as doing things right
swwweet
225
10k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
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]