Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Structs, Methods, and Inter | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 7 of 60

·Go

Structs, Methods, and Interfaces

25 minutes

Course progress12%

Structs

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

Structs group related fields.

type Person struct {
    Name string
    Age  int
}

p := Person{Name: "Bob", Age: 30}

Methods (receiver functions)

func (p Person) Greet() string {
    return "Hello, " + p.Name
}

func (p *Person) HaveBirthday() {
    p.Age++ // pointer receiver mutates the struct
}

Interfaces (behavioral contracts)

type Greeter interface {
    Greet() string
}

func Say(g Greeter) {
    fmt.Println(g.Greet())
}

Say(p) // Person implements Greeter

Interfaces are satisfied implicitly – no implements keyword.

Info

Use a pointer receiver when the method needs to modify the receiver or avoid copying large structs.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonArrays, Slices, and MapsContinue to lesson 8Error Handling & DeferBack to Go Programming Bootcamp curriculum