I have a struct defined as shown below :
type abc struct {
srcName string
destName string
flag bool 'default:false'
}
In my code , i initialize it with make function
var abcList []abc
func init() {
abcList = make([]abc, 1)
}
func main() {
var abcElem abc
abc.srcName = "src"
abc.destName = "dest"
abc.flag = true
abcList = append(abcList, abc)
klog.Info("abcList:", abcList)
}
I see the output as:
abcList: [{ false} {"src", "dest", true}]
Want to know why slice element with default value is added. Isn't it a wrong thing? If i initialize this slice with bigger capacity, then i see many such elements with default value. It adds extra cost while iterating this slice.