I have the following range over a slice of a specific struct:
var t1, t2 *time.Time
for _, d := range entries {
if d.EntryType == print {
t1 = &d.LogTime
}
if d.EntryType == saw {
t2 = &d.LogTime
}
}
In my example I have two objects in my struct and I know that they are different. But when I Println both Time pointers with String or when I make some calculations, I can see that both have the same value of the second one.
When I change the assignment to
tmp := d.LogTime
t1 = &tmp
i can make my calculations, because both pointers are pointing to different objects.