© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
R. Hussain, M. ZulfiqarBeginning Go Programminghttps://doi.org/10.1007/978-1-4842-8858-0_5

5. Structs, Methods, and Interfaces

Rumeel Hussain1   and Maryam Zulfiqar2
(1)
Dubai, United Arab Emirates
(2)
Lahore, Pakistan
 

Go supports structs (short for structures) that allow programmers to define user-defined types. Related data that exhibits a “has-a” relationship can be grouped into a single logical unit using structs. Methods in Go are functions that can be tied to user-defined types to define their behavior. Another important feature of the Go language is the concept of interfaces. In Go, structs and interfaces go hand in hand to organize methods and data handling. ...

Get Beginning Go Programming: Build Reliable and Efficient Applications with Go 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.