I think you meant
type Human struct {
Name string
MaybeHasCat *Cat
}
As you have written (not making MaybeHasCat a pointer), go will correctly initialize (at least as of go1.20.5) the nested Cat structure and allow for direct assignment.Having a null pointer exception for a null pointer is a behavior I would expect. Having one for a non-pointer structure would be surprising.