I’ve been going through and trying to understand the examples on the Go website and I keep coming across a special asterisk character in examples like this:
s := "hello"
if s[1] != 'e' {
os.Exit(1)
}
s = "good bye"
var p *string = &s
*p = "ciao"
Also, I just noticed, what’s with the &s? Is it assignment by reference (I might be using PHP talk here)?
Im guessing it means the same as in C
p is a pointer to a stringThe statement
var p *string = &swould assign the address of thesobject topNext line
*p = "ciao"would change the contents ofsSee this link from the Language Design FAQ
Interestingly, no pointer arithmetic