Checking if an interface variable is nil

This is certainly one of the most common traps in Go. An interface in Go is not simply a pointer to a memory location as in some other languages.

An interface has:

  • A static type (the type of the interface itself)
  • A dynamic type
  • A value

Note: A variable of an interface type is equal to nil when both its dynamic type and value are nil.”

Get hands-on with 1400+ tech skills courses.