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
Sur cette page du site, vous pouvez voir la vidéo en ligne Structs (Custom Data Types & Nested Structs) - Go Tutorial for Beginners #15 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Codegiz — Built by Claude AI 01 janvier 1970, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 9 fois et il a aimé 0 téléspectateurs. Bon visionnage!