我是Golang Newbie,但我认为我有指针和参考文献的基本内容,但显然不是:

[]github.Repository
allRepos
func (s *inmemService) GetWatchedRepos(ctx context.Context, username string) ([]github.Repository, error) {
    s.mtx.RLock()
    defer s.mtx.RUnlock()

    opt := &github.ListOptions{PerPage: 20}

    var allRepos []github.Repository

    for {
        // repos is of type *[]github.Repository
        repos, resp, err := s.ghClient.Activity.ListWatched(ctx, "", opt)

        if err != nil {
            return []github.Repository{}, err
        }

        // ERROR: Cannot use repos (type []*github.Repository) as type github.Repository
        // but dereferencing it doesn't work, either
        allRepos = append(allRepos, repos...)
        if resp.NextPage == 0 {
            break
        }
        opt.Page = resp.NextPage
    }

    return allRepos, nil

}
[]github.Repository
allRepos = append(allRepos, repos...)allRepos = append(allRepos, *(repos)...)
Invalid indirect of (repos) (type []*github.Repository)