Go won't hold your hands because it's more efficient if you are explicit. If you want a "reference" to the real original, your array needs to be an array of pointers.
It's pretty simple to understand when you have worked with pointers before and understand how the memory is allocated and eventually collected (and why you don't want to reallocate every loop iteration).
Finally, nil is the default value of anything with type (star)Student, and almost nobody uses arrays in Go ([2]Student is an array, []Student is a much-more-useful slice). In general, I don't think this author has written much Go code. It's probably a good idea to get a little more experience with whatever you're complaining about before writing a blog post about it, and likely misinforming your readers.
It's pretty straightforward code when you write what you explicitly want:
package main
import (
"fmt"
)
type Student struct {
name string
}
func main() {
students := []*Student{{"fred"}, {"karen"}}
var fredPtr *Student
for _, student := range students {
if student.name == "fred" {
fredPtr = student
}
}
fmt.Println(fredPtr.name)
}The title has to do with a common use case of Go, referred to in the opening example, where it is a common choice to move to from Python for speed.
> It's just pointing out a language gotcha/subtlety.
The implied motivation for posting this (see the closing line) is that the author has see this bite people coming to Go from Python.