```go
type MusicManager struct {
musics []MusicEntry
}
func (m *MusicManager) Get(index int) (music *MusicEntry, err error) {
if index < 0 || index >= len(m.musics) {
return nil, errors.New("Index out of range.")
}
return &m.musics[index], nil
}
func (m *MusicManager) Add(music *MusicEntry) {
m.musics = append(m.musics, *music)
}
```
go语言编程这本书中的音乐库的示例
请问这里add 为什么要引用 MusicEntry ??
更多评论
```go
type MusicManager struct {
musics []MusicEntry
}
```
结构中有 `MusicEntry`,add 进来不是应该的吗?要不然呢?
#1