In the first code example, I get errors for the "if pr != nil" line:
for sup, _ := range supervisorToColor {
pr := emailToPerson[sup]
// The line below causes the compilation error:
// ./myprog.go:1046: missing condition in if statement
// ./myprog.go:1046: pr != nil evaluated but not used
if pr != nil
{
local := peopleOnFloor[pr.Email]
sp := &Super{pr, local}
names = append(names, sp)
}
}
If I comment out the nil check if statement, it compiles fine:
for sup, _ := range supervisorToColor {
pr := emailToPerson[sup]
// if pr != nil
// {
local := peopleOnFloor[pr.Email]
sp := &Super{pr, local}
names = append(names, sp)
// }
}
At first I was inclined to think it was some syntax error earlier in the code, but the fact that it works when I comment out the lines makes me think it's something else.
emailToPerson is of type map[string]*Person where Person is a struct
Thanks in advance. Apologies if this turns out to be something incredibly simple.