type ImageData struct {
src string
tp string
title string
width int
height int
}
type ImageDatas []ImageData
// 现在我这样得到一个ImageData:
imageData := ImageData{src, tp, title, wd, hg}
// 但是怎么把imageData加入到ImageDatas中呢?最后怎么遍历出所有数据呢?
imagedatas = append(imagedatas, imagedata)参考示例:
https://gobyexample.com/slices
s := make([]string, 3)
fmt.Println("emp:", s)
s[0] = "a"
s[1] = "b"
s[2] = "c"
fmt.Println("set:", s)
fmt.Println("get:", s[2])
fmt.Println("len:", len(s))
s = append(s, "d")
s = append(s, "e", "f")
fmt.Println("apd:", s)