Values & References8 / 15
Up next

Struct assignment copies

package main

import "fmt"

type Point struct{ X, Y int }

func main() {
	a := Point{1, 2}
	// b is an independent copy
	b := a
	b.X = 99
	fmt.Println(a.X, b.X) // 1 99
}
What you're solving

assigning duplicates every field