I have checked several other answers and they gave me some good thoughts on how to troubleshoot this but I still can't figure it out.
localID := generateGenericID("local") // type int64
localName := "local" // type string
// set them to pointers as I need them as type *int64 and *string
plocalID := &localID
plocalName := &localName
// create a pointer to a new github org
var org *github.Organization
// create a new general purpose org
o := Org{}
// Check for nil, per several other answers
if plocalName != nil {
o.Name = plocalName
org.Login = plocalName // ERROR
}
if plocalID != nil {
o.ID = plocalID
org.ID = plocalID
}
fmt.Println(*plocalName) // prints local
hunt.addOrganization(org) // takes a pointer to a github org
report.addReportOrganization(&o) // take a pointer to an org
The error message I am getting is:
panic: runtime error: invalid memory address or nil pointer
It points to the line marked ERROR
. The error makes no sense due to me checking for nil, so I am wondering if maybe I am some kind of pointer hell due to creating a variable that is a pointer and then assigning pointers to it.
Should I simply create the github org as a normal struct and then pass in &org
to the hunt function. I tried that and got past the error but a ton of other code pukes so before I start to chase this down I figured I would ask if that even makes sense of if I am looking in the wrong spot. RTFM with links is always welcome.
Thanks!