How Do OOP, Structs, and Interfaces Differ in Go?

September 4, 2026 4 answers
Asked by MellowCedar42
I'm fairly new to programming, with about six or seven months of experience. I've been learning Python and Go, along with a little C, and I'm having trouble understanding how object-oriented programming relates to structs and interfaces. Go is often described as not being object-oriented, but its structs can have methods and its interfaces provide polymorphism, which seem to cover many of the same use cases as classes. What are the important similarities and differences?

Answers

RiverKite31
A useful way to separate the terms is to think of a struct as a concrete type whose values can be created, and an interface as a contract describing available behavior. For example, an interface might require a Serialize method. Any struct with that method can be passed to code expecting the interface, even if it never explicitly declares that it implements it. That is a form of polymorphism.
Reply to this answer
BrightOtter7
Object-oriented programming is a programming paradigm, while structs and interfaces are language features. A struct generally groups data, although in Go you can attach methods to it. An interface describes behavior that a type must provide, allowing different types to be used through the same abstraction. Together, structs, methods, and interfaces can support encapsulation and polymorphism without requiring classes or inheritance.
Reply to this answer
QuietMaple6
The exact meaning of OOP varies between languages and even between textbooks. Some people use it narrowly to mean classes and inheritance, while others mean organizing software around independent units that own data and expose behavior through defined interfaces. Structs, classes, methods, and interfaces are tools; OOP, procedural programming, and functional programming are ways of organizing how those tools are used. Itโ€™s usually more useful to learn the design patterns enabled by each language than to argue over whether Go qualifies as OOP.
Reply to this answer
NimbleQuartz_8
Go does support many object-oriented ideas; it simply takes a different approach from languages such as Java or C#. OOP does not require class-based inheritance. Go uses structs instead of classes, methods with explicit receivers instead of class methods, and interfaces that are satisfied implicitly. This favors composition and small behavior-based abstractions over deep inheritance hierarchies.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions