无法获得golang中最重要的频道的列表

I am trying to create a bot and retrieve the list of channels. I used the bot example in repository and it is mostly working, except for the part where it has to get the list of channels.

Either I am doing something silly or GetChannels API really does not work the way it is described in bot_sample.go . I made a smaller separate function to test that part.

Adding code here for better readability:

func mattermostPrintChannels(client *mattermost.Client) {
    channelsResult, err := client.GetChannels("")
    if err != nil {
        fmt.Print("Couldn't get channels: ", err)
        return
    }
    channelList := channelsResult.Data.(*mattermost.ChannelList)
    fmt.Print("Channels:")
    for _, channel := range channelList.Channels {
        fmt.Printf("%s -> %s", channel.Id, channel.DisplayName)
    }
}

This code gives me the error:

./mattermost.go:30: channelList.Channels undefined (type *model.ChannelList has no field or method Channels)

Now if I just print the contents of ChannelList variable (using spew), I get the following:

channelList:  :  ([]interface {}) (len=1 cap=1) {
 (*model.ChannelList)(<nil>)
}

JimB is correct. The model.ChannelList type used to be a struct, but it recently changed to []*model.Channel. You'll want to change

for _, channel := range channelList.Channels {

to

for _, channel := range *channelList {