Passing pointer of string to a function leads to the wrong string being printed
I have the following program (simplified as much as possible): package main import "fmt" type Test struct { Str *string } func main() { arr := []string{"vanC", "vanD"} arr2 := make([]Test, 0) for _, element := range arr { fmt.Println(element, &element) arr2 = append(arr2, Test{ Str: &element, }) } fn(arr2) } func fn(arr2 []Test) {… Read More Passing pointer of string to a function leads to the wrong string being printed