具有值数组的Golang映射
这句话在围棋中是什么意思:具有值数组的Golang映射,go,Go,这句话在围棋中是什么意思: Student.bookMap=map[string][]*model.Books{} 其中Student是: type Student struct{ bookMap map[string][]*model.Books } 我们有一个模型包 package model type Books struct { bookName string `db:"Name"` bookAuthor string `db:"Author"` }
Student.bookMap=map[string][]*model.Books{}
其中Student
是:
type Student struct{
bookMap map[string][]*model.Books
}
我们有一个模型包
package model
type Books struct {
bookName string `db:"Name"`
bookAuthor string `db:"Author"`
}
这意味着
struct
Student
的成员bookMap
包含一个map
,它将字符串作为键,并将指向model.Books
实例的指针数组(切片)作为值。该语句正在将mapStudent.bookMap
初始化为空映射(它具有以下结构:key->字符串
,value->model.Books的指针切片
)