summaryrefslogblamecommitdiffstats
path: root/vendor/layeh.com/gumble/gumbleutil/channel.go
blob: ecf8bbef558e009f09c368e3b47a943b127e4cb8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
















                                                                                       
package gumbleutil

import (
	"layeh.com/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
}