I have initialized a struct :
type DayAndTime struct {
days string
time string
}
I have initialized an empty set of array of this DayAndTime type:
day := []DayAndTime{}
And put a value in it:
day[0] = DayAndTime{"Monday", "8.00 PM"}
But it shows a runtime error:
panic: runtime error: invalid memory address or nil pointer dereference
Why is this happenning and what could be a possible solution?
edit: It's actually a slice not an array.