1. 22
  1.  

  2. 3

    The compiler generates checks when dereferencing a pointer. The purpose is to avoid memory corruption by running panic() if the pointer is nil. This is extra code that must be executed at runtime.

    I don’t think that’s true unless go changed its behavior. On Linux go dereferences the pointer and handles the SIGSEGV. So afaik there’s not really any overhead except when you actually dereference something and start a panic.

    1. 2

      Wow, this is one of the most thorough articles I’ve read on performance optimization in Go.