mirror of
https://github.com/diamondburned/cchat-gtk.git
synced 2024-11-17 03:32:56 +00:00
22 lines
408 B
Go
22 lines
408 B
Go
|
package breadcrumb
|
||
|
|
||
|
import "strings"
|
||
|
|
||
|
type Breadcrumb []string
|
||
|
|
||
|
func (b Breadcrumb) String() string {
|
||
|
return strings.Join([]string(b), "/")
|
||
|
}
|
||
|
|
||
|
type Breadcrumber interface {
|
||
|
Breadcrumb() Breadcrumb
|
||
|
}
|
||
|
|
||
|
// Try accepts a nilable breadcrumber and handles it appropriately.
|
||
|
func Try(i Breadcrumber, appended ...string) []string {
|
||
|
if i == nil {
|
||
|
return appended
|
||
|
}
|
||
|
return append(i.Breadcrumb(), appended...)
|
||
|
}
|