Pointers and structures
Pointers are the number one source of a headache of every C or C++ programmer. But they are one of the main tools to achieve high-performance code in non-garbage-collected languages. Fortunately for us, Go's pointers have achieved the best of both worlds by providing high-performance pointers with garbage-collector capabilities and easiness.
On the other side for its detractors, Go lacks inheritance in favor of composition. Instead of talking about the objects that are in Go, your objects have other . So, instead of having a car
structure that inherits the class vehicle
(a car is a vehicle), you could have a vehicle
structure that contains a car
structure within.
What is a pointer? Why are they good?
Pointers are hated, loved, ...
Get Go: Design Patterns for Real-World Projects 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.