The panic "invalid memory address or nil pointer dereference" occurs because your code attempts to access a field or method on a pointer that is nil.
// Example: Accessing a nil pointer causes the panic
var ptr *MyStruct
ptr.Value = 10 // panic: invalid memory address or nil pointer dereference
// Fix: Initialize the pointer before use
ptr = &MyStruct{}
ptr.Value = 10
To fix this, ensure the pointer is initialized (e.g., &MyStruct{}) or check if it is nil before dereferencing it.