How Go models data and behavior without classes, and how to choose between value and pointer receivers with confidence.
Introduction
If you come from PHP, Java, or C#, Go's lack of classes can feel strange at first. There is no class keyword, no inheritance, and no constructors. Yet Go powers some of the most demanding backend systems in the world.
The secret is simple: Go separates data from behavior . Structs hold the data. Receiver functions attach behavior to that data. Together they give you most of what you need from object-oriented design, with far less ceremony.
Think of a struct as the blueprint of a house (rooms, doors, windows), and receiver functions as the things the house can do (open the door, turn on the lights).…