Structs (Custom Data Types & Nested Structs) - Go Tutorial for Beginners #15

Опубликовано: 01 Январь 1970
на канале: Codegiz — Built by Claude AI
9
0

Master structs in Go - create your own custom data types!

In this lesson, you will learn:
✓ Defining struct types
✓ Creating struct instances
✓ Named fields vs positional initialization
✓ Accessing and modifying fields
✓ Struct copying (by value)
✓ Struct comparison
✓ Nested structs
✓ Anonymous structs for one-time use

⏱️ Timestamps:
0:00 - Introduction
0:27 - Struct Basics
2:45 - Modifying Struct Fields
4:58 - Nested Structs
7:19 - Anonymous Structs
9:34 - Recap
10:04 - End

💻 Source Code: https://github.com/GoCelesteAI/go_str...

📝 Code Highlights:

// Define a struct
type Person struct {
Name string
Age int
City string
}

// Create with named fields (preferred)
p := Person{Name: "Alice", Age: 25, City: "NYC"}

// Access fields with dot notation
fmt.Println(p.Name) // Alice
p.Age = 26 // Modify field

// Nested structs
type Employee struct {
Name string
Address Address // Nested struct
}
fmt.Println(emp.Address.City) // Access nested field

// Anonymous struct (one-time use)
config := struct {
Host string
Port int
}{
Host: "localhost",
Port: 8080,
}

// Structs are copied by value
copy := original // Independent copy

📺 Full Playlist: Go Tutorial for Beginners
📺 Previous: Lesson 14 - Pointers
📺 Next: Lesson 16 - Struct Methods

👍 Like and Subscribe for more Go tutorials!

#Go #Golang #Programming #Tutorial #Structs #DataTypes #OOP #LearnToCode


На этой странице сайта вы можете посмотреть видео онлайн Structs (Custom Data Types & Nested Structs) - Go Tutorial for Beginners #15 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Codegiz — Built by Claude AI 01 Январь 1970, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 9 раз и оно понравилось 0 зрителям. Приятного просмотра!