Structures in Go
syntax
type dragon struct {
Name string
Height int
}Basic struct call example
package main
import (
"fmt"
)
type dragon struct {
Name string
Height int
}
func main() {
dragons := dragon{"trex", 10000}
fmt.Println(dragons.Height)
// you can also assign using dot operator
dragon.name = "participants"
}struct with Pointer
Return from function
methods on structure
Last updated