我有 2 个结构,里面有一个切片,如下所示:
type BookX struct {
SomeValue string
Book1 []Book1
}
type Book1 struct {
Name string
Author string
}
type BookY struct {
SomeValue string
Book2 []Book2
}
type Book2 struct {
Name string
Author string
}
我想将结构 BookX 中第一个切片中的值传递给 BookY 中的另一个切片。
尝试过这种方式但不起作用:
func someName(bookX BookX){
var bookY BookY
bookY.Book2 = append(bookY.Book2, bookX.Book1...)
}
叮当猫咪
相关分类