func (server *Server) AddChannel(channel *Channel) {
	if _, _, ok := server.HasChannel(channel.Name); !ok {
		server.mu.Lock()
		defer server.mu.Unlock()
		channel.Server = server
		server.Channels = append(server.Channels, channel)
	}
}
AddChannel to server channel list
package client
import (
	"errors"
	"sync"
	ircClient "github.com/fluffle/goirc/client"
	"github.com/hectane/go-nonblockingchan"
	"github.com/jroimartin/gocui"
	"github.com/mephux/komanda-cli/komanda/helpers"
)
const (
	StatusChannel = "komanda-status"
)
var (
	layoutViews = []string{"header", "input", "menu"}
)
type Server struct {
	Gui      *gocui.Gui
	Client   *ircClient.Conn
	Channels []*Channel
	Address      string
	Port         string
	SSL          bool
	User         string
	Password     string
	NickPassword string
	Nick    string
	AltNick string
	Version            string
	CurrentChannel     string
	InsecureSkipVerify bool
	AutoConnect        bool
	mu sync.Mutex
}
type Handler func(*Channel, *gocui.Gui, *gocui.View, *Server) error
func (server *Server) Exec(channel string, h Handler) {
	server.Gui.Update(func(g *gocui.Gui) error {
		if helpers.Contains(layoutViews, channel) {
			v, err := g.View(channel)
			if err != nil {
				return err
			}
			return h(nil, server.Gui, v, server)
		}
		c, _, has := server.HasChannel(channel)
		if has {
			v, err := c.View()
			if err != nil {
				return err
			}
			return h(c, server.Gui, v, server)
		}
		server.NewChannel(channel, false)
		newC, _, newHas := server.HasChannel(channel)
		if newHas {
			v, err := newC.View()
			if err != nil {
				return err
			}
			server.CurrentChannel = channel
			return h(newC, server.Gui, v, server)
		}
		return errors.New("error creating channel")
	})
}
func (server *Server) HasChannel(name string) (*Channel, int, bool) {
	for i, channel := range server.Channels {
		if name == channel.Name {
			return channel, i, true
		}
	}
	return nil, -1, false
}
func (server *Server) FindChannel(name string) *Channel {
	c, _, has := server.HasChannel(name)
	if has {
		return c
	}
	return nil
}
func (server *Server) ChannelView(name string) (*gocui.View, error) {
	if c, _, ok := server.HasChannel(name); ok {
		return c.View()
	}
	return nil, errors.New("channel not found")
}