Go

Structs in Go

Gagandeep Singh
Struct in Go allows to create custom data types. In the example below User is a struct type, it’s defined using the type keyword followed by the struct name and then struct. Struct can have once or more fields in it and fields are defined using name and type. For example: package main import "fmt" func main() { type User struct { firstname, lastname string age int } u1 := User{ firstname: "Gagandeep", lastname: "Singh", age: 32} fmt.