To a slice of strings you can either append a string, or use the dot-dot-dot syntax to append all the elements of another slice of strings. Your example is in between those two working variants, so you need to decide if Title1 should be a string or if you mean Title1....
Which you did not even mention in your original post, instead you have choosen a title which suggests that you are mismatching a string and a pointer to a string somewhere…
Please try to ask your questions the smart way.
Do not just throw code at the forum and assume that everyone will be knowing what you are working at. Especially do not assume, that everyone is willing to download libraries which are potentially unrelated to your problem (the mysql driver in this case).
Also please do actually provide a question and not just code and “thanks”…
Currently @calmh, @lutzhorn and me are in a mood to pull the details out of your noses, but currently, there are a lot of threads, which are just a near-to-useless topic and a bulk of code which is partially unrelated to the problem and not runnable at all because of missing pieces.
Our mood to ask for the details might vanish if it continous to feel as if there is no effort by you and the other ones.
Also we have often enough given away tipps about how to ask a question, but at least I do not see that the quality of question is getting better.
So at the end, you need to say sorry to yourself…
Thanks @calmh…I got it from your advice. Intelligent people giving a small piece of advice but very useful. I did it this way.
type a struct {
Title []b
Title1 []b
Article [][]b
}
type b struct{
DD string
FF int
}
type c struct{
CC string
EE string
}
type d struct{
DD string
}
func main() {
xx:=b{}
Title:=[]b{}
yy:=b{}
Title1:=[]b{}
Article:=[][]b{}
for i:=0; i<=2; i++{
xx.DD=strconv.Itoa(i)+"a"
xx.FF=i
Title=append(Title,xx)
Title1=nil
for ii:=0; ii<=2; ii++{
yy.DD=strconv.Itoa(ii)
Title1=append(Title1,yy)
}
fmt.Println(Title1)
Article=append(Article,Title1)
}
var data = &a{
Title: Title,
Article: Article,
}
fmt.Println(data)
tmpl := template.Must(template.New("test").Parse(tmplSrc))
tmpl.Execute(os.Stdout, data)
}