How can I pass something to a function such that it is modifiable and can be seen in the calling stack ? ( in other words how to pass a pointer or a reference ? )
package main
import (
"os/exec"
"fmt"
)
func process(names *[]string) {
fmt.Print("Pre process", names)
names[1] = "modified"
}
func main() {
names := []string{"leto", "paul", "teg"}
process(&names)
fmt.Print("Post process", names)
}
Error:
invalid operation: names[0] (type *[]string does not support indexing)