Struct Fields

Struct fields are accessed using a dot.

struct-fields.go

  1. package main
  2. import "fmt"
  3. type Vertex struct {
  4. X int
  5. Y int
  6. }
  7. func main() {
  8. v := Vertex{1, 2}
  9. v.X = 4
  10. fmt.Println(v.X)
  11. }