I have a struct B which inherits from the struct A. I have another struct C (which contains a slice of structs A) and I want to append B to C.
package main
type A struct {
target string
}
type B struct{
A
values []int
}
type C struct{
Cols []*A
}
func main() {
var values = []int{1,2,3}
var col1 = C{}
var col2 = &B {
A: A{
target: "txt",
},
values: values,
}
col1.Cols = append(col1.Cols, col2)
}
When running this code, it generates an error: cannot use col2 (type *B) as type *A in append
What's wrong please ? I'm newer
Ps: sorry for my bad English