#My Pointer has stopped working :(

6 messages · Page 1 of 1 (latest)

graceful wave
#

This was working last night, and all I've done today is add an extra values field in the helm option chart. Now I'm getting:

Added Chart Repo argo
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x23c1a7f]

goroutine 1 [running]:
main.main()
        C:/DevOps/argo-cd-demo/deployArgoCDGo/main.go:124 +0x39f
exit status 2Added Chart Repo argo
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x23c1a7f]

goroutine 1 [running]:
main.main()
        C:/DevOps/argo-cd-demo/deployArgoCDGo/main.go:124 +0x39f
exit status 2Added Chart Repo argo
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x23c1a7f]

goroutine 1 [running]:
main.main()
        C:/DevOps/argo-cd-demo/deployArgoCDGo/main.go:124 +0x39f
exit status 2

Here is my full code: https://go.dev/play/p/c1rfgDJQTeU

Its happening on this line: fmt.Printf("Status of Chart Install %v,\n", *myInstalledHelmChart.Info)

I can't for the life of me figure out how to get around this problem. It was working last night.

I've tried to implement a generics pointer, but that hasn't worked as the type is *release.Release, which is a struct, but I can't figure out how to tell the function to expect a struct.

Any help would be greatly appreciated.

tidal gorge
#
myInstalledHelmChart, _ := myHelmClient.InstallChart(mycontext, &chartSpec, nil)
fmt.Printf("Status of Chart Install %v,\n", *myInstalledHelmChart.Info)

Is the second return value an error? If so, it might be worth it to see what data is being returned for both: ```go
myInstalledHelmChart, err := myHelmClient.InstallChart(mycontext, &chartSpec, nil)
fmt.Printf("returned data: %v %v\n", *myInstalledHelmChart, err)

graceful wave
#

So, it is an error, but it's not very good; it just gives me the status of the deployment, and the deployment is currently exceeding context, so that is why I'm ignoring it. The change I just made should fix it, but I want to see the status first before enabling the error.

#

PS love your profile pic

#

Would you happen to know, How I would pass the struct through the generics function?

func Ptr[T any](v T) *T {
    return &v
}

fmt.Printf("Status of Chart Install %v %v,\n", ptr({struct}, myInstalledHelmChart.Info), err) this isnt working

warped grove
#

Soo when a function returns an error and a value and the error is not nil, the value will often be nil or otherwise not useful. You'll likely need to deal with the underlying error instead of ignoring it