This repository has been archived on 2019-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mumbledj/vendor/github.com/layeh/gumble/gumbleutil/channel.go
2016-06-20 17:50:40 -07:00

19 lines
474 B
Go

package gumbleutil
import (
"github.com/layeh/gumble/gumble"
)
// ChannelPath returns a slice of channel names, starting from the root channel
// to the given channel.
func ChannelPath(channel *gumble.Channel) []string {
var pieces []string
for ; channel != nil; channel = channel.Parent {
pieces = append(pieces, channel.Name)
}
for i := 0; i < (len(pieces) / 2); i++ {
pieces[len(pieces)-1-i], pieces[i] = pieces[i], pieces[len(pieces)-1-i]
}
return pieces
}