Keep packages backwards compatible

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Keep packages backwards compatible

FOSDEM 2017 talk on keeping Go packages backwards compatible

Ernesto Jiménez

February 05, 2017

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

24 slides
  1. package example type Service struct { // ... } func

    New() *Service { return &Service{} }
  2. package example func Process(in input) error { // ... }

    // ⚠ type input interface { // ... }
  3. // Input exported for documentation type Input interface { //

    ... } func Process(in Input) error { // ... }
  4. package testing type TB interface { Error(args ...interface{}) Fail() //

    ... // contains filtered or unexported methods }
  5. 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() }
  6. // 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 } }

More Decks by Ernesto Jiménez

Other Decks in Programming