英文:
Golang Map with array of values
问题
这个Go语言语句的含义是:创建了一个空的map类型变量bookMap,其键类型为string,值类型为[]*model.Books。这个map变量属于Student结构体类型。
在这里,Student是一个结构体类型,它包含了一个名为bookMap的成员变量,其类型为map[string][]*model.Books。
同时,我们还有一个model包,其中定义了Books结构体类型。Books结构体包含了bookName和bookAuthor两个成员变量,它们的类型分别为string,并且使用了db:"Name"和db:"Author"的标签。
英文:
What does this statement mean in Go:
Student.bookMap=map[string][]*model.Books{}
Where Student is:
type Student struct{
bookMap map[string][]*model.Books
}
and we have a model package
package model
type Books struct {
bookName string `db:"Name"`
bookAuthor string `db:"Author"`
}
答案1
得分: 1
该语句将地图Student.bookMap初始化为空地图(其结构如下:键 -> string,值 -> model.Books指针的切片)。
英文:
That statement is initializing the map Student.bookMap to an empty map (which has the following structure: key -> string, value -> slice of pointers of model.Books).
答案2
得分: 0
这意味着struct类型的Student中的成员bookMap包含一个map,该map以string作为键,以指向model.Books实例的指针数组(切片)作为值。
英文:
It means the member bookMap of a struct Student contains a map which takes a string as a key, and an array (slice) of pointers to instances of model.Books as value.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论