RANIARANIA Academy

Structs, Methods & Interfaces

Model data and behaviour with Go's type system by defining structs, attaching methods, and designing with interfaces. You will learn embedding and composition, when to use pointer versus value receivers, how implicit interface satisfaction works, and how to encapsulate state cleanly — so you can honestly design idiomatic Go types on the job.

Watch the free preview

Defining structs and creating values — free to watch, no account needed.

Go (Golang) BEGINNER · 150 min · Certificate on completion · 3 CPD points

What you'll learn

  • Model data and behaviour with Go's type system using structs, methods and interfaces
  • Compose types with struct embedding and promoted fields instead of inheritance
  • Choose correctly between pointer and value receivers for methods
  • Design and satisfy interfaces implicitly, including the empty interface and type switches
  • Encapsulate state with packages, exported identifiers and constructor functions

Syllabus

Modelling Data with Structs
Defining structs and creating valuesFree preview15 min
Composition and embedding15 min
Adding Behaviour with Methods
Methods and receivers15 min
Pointer vs value receivers15 min
Interfaces and Implicit Satisfaction
Defining and satisfying interfaces15 min
Designing with small interfaces15 min
The Empty Interface, Type Assertions & Encapsulation
The empty interface, assertions and type switches15 min
Encapsulation with packages and exported names15 min
Lab — 10 Exercises & Solutions
Exercises 1–515 min
Exercises 6–1015 min