Structs in Go

 Structs in Go


Go supports user-defined types called structs, which allow you to group together related data into a single object.



type Person struct {

    Name string

    Age  int

}


var p Person = Person{"John", 30} // declare and initialize a Person struct

fmt.Println(p.Name)              // prints "John"

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...