GopherCon 2019 - Detecting Incompatible API Changes

conference, golang, gophercon2019, notes

These are some notes from my experiences at the GopherCon 2019. I don’t expect these will be laid out in any particularly useful way; I am mostly taking them so I can remember some of the bits I found most useful in the future.


Problem

  • Want to make sure breaking changes weren’t being introduced

    • Especially difficult for generated code
    • And unexported can even break things
  • Build a tool!

  • Or just don’t make incompatible changes

What is Compatibility?

  • compile-time compatibility

  • exclude type spoofing

  • exclude unkeyed struct litarals

    • hack: include _ struct{} in a struct body to force keyed literals
  • exclude use of unsafe

The Code

  • how to compare? by name?

    • name doesn’t work for types (aliases)
    • aliases still aren’t enough (exported variables pointing to unexported types with exported fields)
  • comparisons are somewhat complicated

Code

  • /x/exp/cmd/apidiff
  • future: go release