Chapter 5. Go’s type system

In this chapter

  • Declaring new user-defined types
  • Adding behavior to types with methods
  • Knowing when to use pointers and values
  • Implementing polymorphism with interfaces
  • Extending and changing types through composition
  • Exporting and unexporting identifiers

Go is a statically typed programming language. What that means is the compiler always wants to know what the type is for every value in the program. When the compiler knows the type information ahead of time, it can help to make sure that the program is working with values in a safe way. This helps to reduce potential memory corruption and bugs, and provides the compiler the opportunity to produce more performant code.

A value’s type provides the compiler ...

Get Go in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.