I am trying to change a value within a struct. Unfortunately, the value in "" ==>", flow" doesn't change. I don't understand why.
Can you help me to explain why the pointer doesn't correspond in Slice. May be I must write a slice of pointer ?
Thank you in advance.
package main
import (
"fmt"
)
type Foo struct {
value float64
}
var flows []Foo;
func AddFoo(foo Foo) {
flows = append(flows, foo)
}
func UpdateFoo(stream *Foo) {
stream.value = 5.00
}
func main() {
x := Foo{1.00}
AddFoo(x)
UpdateFoo(&x)
fmt.Println(x)
for _, flow := range flows {
fmt.Println(" ==>", flow)
}
}