Structs define data and methods, while interfaces provide polymorphism. Probably easiest to understand with an example: package main import "fmt" // Define an interface that both structs will implement type Animal interface { Speak() string Move() string } // Dog struct is a type with one field, but they usually have many fields type Dog struct { Name string } // Speak implementation for Dog, matches same function in the interface func (d Dog) Speak() string { return fmt.Sprintf("%s says: Woof!", d.Name) } // Move implementation for Dog, matches same function in the interface func (d Dog) Move() string { return fmt.Sprintf("%s runs around happily.", d.Name) } // Define a similar struct for Cat. Note that the fields here do not need // to be the same as Dog. An interface knows nothing about these fields. type Cat struct { Name string } func (c Cat) Speak() string { return fmt.Sprintf("%s says: Meow!", c.Name) } func (c Cat) Move() string { return fmt.Sprintf("%s gracefully walks away.", c.Name) } // Function that accepts the interface as an argument, in other words, // any struct that has those Speak and Move methods defined func DescribeAnimal(a Animal) { fmt.Println(a.Speak()) fmt.Println(a.Move()) fmt.Println() } func main() { dog := Dog{Name: "Buddy"} cat := Cat{Name: "Misty"} // Both structs satisfy the Animal interface DescribeAnimal(dog) DescribeAnimal(cat) } Answer from axvallone on reddit.com
๐ŸŒ
Go by Example
gobyexample.com โ€บ structs
Go by Example: Structs
Goโ€™s structs are typed collections of fields. Theyโ€™re useful for grouping data together to form records ยท This person struct type has name and age fields
๐ŸŒ
W3Schools
w3schools.com โ€บ go โ€บ go_struct.php
Go Struct
A struct (short for structure) is used to create a collection of members of different data types, into a single variable.
๐ŸŒ
DEV Community
dev.to โ€บ jpoly1219 โ€บ structs-methods-and-receivers-in-go-5g4f
Structs, Methods, and Receivers in Go - DEV Community
January 30, 2023 - People who have used another programming language, most likely Python or Javascript, may notice that Go does not have a class, only structs. Some might wonder how structs differ from classes. It turns out that they are actually pretty similar!
๐ŸŒ
Reddit
reddit.com โ€บ r/golang โ€บ can someone give me a simple explanation of the point of structs and interfaces, and what they do?
r/golang on Reddit: Can someone give me a simple explanation of the point of structs and interfaces, and what they do?
October 16, 2025 -

Started learning Go today as my second language and I'm having trouble understanding structs and interfaces. So, interfaces define the functions a type should have? And structs group related data together, like objects in JS/TS? But if you can attach functions to structs then wouldn't that struct have functions in it therefore also acting as an interface?? I'm confused, I don't know if this is like Go's little cute take on OOP or what, I've asked ChatGPT to explain it to me like 4 times and I've read the examples on gobyexample and I watched a video, but still don't get it, I probably just need some hands-on practice, but I want to see if I can understand the concept first. I'd appreciate it if anybody has an easy explanation on what's the use of having structs and interfaces instead of structs OR interfaces, or what they're used for, like in what situation do you use one or the other, and overall what makes interfaces useful.

Top answer
1 of 30
106
Structs define data and methods, while interfaces provide polymorphism. Probably easiest to understand with an example: package main import "fmt" // Define an interface that both structs will implement type Animal interface { Speak() string Move() string } // Dog struct is a type with one field, but they usually have many fields type Dog struct { Name string } // Speak implementation for Dog, matches same function in the interface func (d Dog) Speak() string { return fmt.Sprintf("%s says: Woof!", d.Name) } // Move implementation for Dog, matches same function in the interface func (d Dog) Move() string { return fmt.Sprintf("%s runs around happily.", d.Name) } // Define a similar struct for Cat. Note that the fields here do not need // to be the same as Dog. An interface knows nothing about these fields. type Cat struct { Name string } func (c Cat) Speak() string { return fmt.Sprintf("%s says: Meow!", c.Name) } func (c Cat) Move() string { return fmt.Sprintf("%s gracefully walks away.", c.Name) } // Function that accepts the interface as an argument, in other words, // any struct that has those Speak and Move methods defined func DescribeAnimal(a Animal) { fmt.Println(a.Speak()) fmt.Println(a.Move()) fmt.Println() } func main() { dog := Dog{Name: "Buddy"} cat := Cat{Name: "Misty"} // Both structs satisfy the Animal interface DescribeAnimal(dog) DescribeAnimal(cat) }
2 of 30
12
Interfaces are ad hoc polymorphism. As opposed to subtype polymorphism (aka inheritance, which is considered bad OO design) or parametric polymorphism (which is generics, which Go also has). What's polymorphism? It's a way to loosen the type system a bit so that you can take multiple types of things as a parameter instead of specifying exactly one type. What makes it ad hoc? Because you are saying that the kind of parameter you're accepting isn't just one thing, but the set of all things which have a certain group of methods. Those methods aren't from some predefined set, but rather specified "on the spot" (ad hoc) when you define the interface. All OO languages have interfaces in some form even if they don't call them that. And that's really the heart of OOP. So what exactly is an interface? It's a set of types. Which types are in that set is determined by whether or not they implement the methods specified by that interface's definition.
๐ŸŒ
Medium
leapcell.medium.com โ€บ deep-dive-into-go-struct-103961431c64
Go Struct: A Deep Dive
January 2, 2025 - In Go, struct is an aggregate type used for defining and encapsulating data. It allows combining fields of different types. Structs can be seen as custom data types similar to classes in other languages, but they do not support inheritance.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ go language โ€บ structures-in-golang
Structures in Golang - GeeksforGeeks
A structure or struct in Golang is a user-defined type that allows to group/combine items of possibly different types into a single type. Any real-world entity which has some set of properties/fields can be represented as a struct.
Published ย  July 12, 2025
๐ŸŒ
DEV Community
dev.to โ€บ leapcell โ€บ deep-dive-into-go-struct-mf6
Deep Dive into Go Struct - DEV Community
January 2, 2025 - In Go, struct is an aggregate type used for defining and encapsulating data. It allows combining fields of different types. Structs can be seen as custom data types similar to classes in other languages, but they do not support inheritance.
๐ŸŒ
Go 101
go101.org โ€บ article โ€บ struct.html
Structs in Go -Go 101
This article will introduce the basic knowledge of struct types and values in Go.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ go โ€บ structs
Go | Structs | Codecademy
June 20, 2023 - A user-defined type that combines several fields of different data types, but related, forming a collection.
๐ŸŒ
Go
go.dev โ€บ tour โ€บ moretypes โ€บ 5
Struct Literals
A struct literal denotes a newly allocated struct value by listing the values of its fields.
๐ŸŒ
CodeSignal
codesignal.com โ€บ learn โ€บ courses โ€บ go-structs-basics-revision โ€บ lessons โ€บ go-structs-and-methods-an-introduction
Go Structs and Methods: An Introduction
To fully grasp Go's structs, think of them as blueprints for creating complex data types by grouping different pieces of related information. Unlike arrays or slices, which hold data of the same type, structs allow you to mix various data types.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ go language โ€บ go-structs-methods-and-receivers
Go - Structs, Methods, and Receivers - GeeksforGeeks
July 23, 2025 - A struct in Go is a composite data type that groups variables (fields) under a single name.
๐ŸŒ
Mastergolang
mastergolang.github.io โ€บ structs
Master Golang: Structs
Best practices for using Structs in golang, start from introducing the basic use
๐ŸŒ
CodeSignal
codesignal.com โ€บ learn โ€บ courses โ€บ clean-coding-with-go-structures โ€บ lessons โ€บ struct-initialization-in-go-best-practices-for-clean-code
Struct Initialization in Go: Best Practices for Clean Code
Go's struct literal syntax provides a built-in way for efficient initialization, but constructor functions add value by encapsulating initialization logic and validation.
๐ŸŒ
Meetgor
dev.meetgor.com โ€บ techstructive-blog โ€บ golang-structs
Golang: Structs
April 14, 2022 - Structs or Structures in Golang are the sequences or collections of built-in data types as a single type interface. Just like we have int, string, float, and complex, we can define our own data types in golang.
๐ŸŒ
The New Stack
thenewstack.io โ€บ home โ€บ what is a go struct and how do you write one?
What Is a Go Struct and How Do You Write One? - The New Stack
June 19, 2024 - In the Go programming language, a struct (aka โ€œstructureโ€) is a composite data type that makes it possible to group values of different types into a single entity.
๐ŸŒ
Relia Software
reliasoftware.com โ€บ blog โ€บ golang-struct
The Ultimate Guide to Golang Structs with Code Example | Relia Software
April 23, 2025 - In Go programming, a struct (or a structure) is a composite data type that groups together variables under a single name, creating a more complex data structure.