package main
import (
"fmt"
)
func main() {
arr1 := [3]int{1, 2, 3}
arr2 := arr1
arr2[0] = 5
fmt.Println("arr1:", arr1) // Output: arr1: [1 2 3]
fmt.Println("arr2:", arr2) // Output: arr2: [5 2 3]
}
- Import the necessary package, in this case, "fmt".
- Define a
main
function as the entry point of the program. - Create an array
arr1
of type int
with a length of 3 and initialize it with values 1, 2, and 3. - Create another array
arr2
and assign the value of arr1
to it. - Modify the first element of
arr2
to 5. - Print the contents of
arr1
and arr2
using fmt.Println
.