This is my code:
package main
import(
"fmt"
)
type Category struct {
Id int
Name string
}
type Book struct {
Id int
Name string
Categories []Category
}
func main() {
var book Book
book.Id = 1
book.Name = "Vanaraj"
for i := 0; i < 10; i++ {
book.Categories = []Category{
{
Id : 10,
Name : "Vanaraj",
},
}
}
fmt.Println(book)
}
I need to append the values to the categories. The values are appending only one time. But I need to append the values to the array.
How to fix this?