func (c *PubSub) Subscribe(channels ...string) error {
	err := c.subscribe("SUBSCRIBE", channels...)
	if err == nil {
		c.channels = appendIfNotExists(c.channels, channels...)
	}
	return err
}
Subscribes the client to the specified channels.
package redis
import (
	"fmt"
	"net"
	"sync"
	"time"
	"gopkg.in/redis.v5/internal"
	"gopkg.in/redis.v5/internal/pool"
)
type PubSub struct {
	base baseClient
	cmd  *Cmd
	mu       sync.Mutex
	channels []string
	patterns []string
}
func (c *PubSub) conn() (*pool.Conn, bool, error) {
	cn, isNew, err := c.base.conn()
	if err != nil {
		return nil, false, err
	}
	if isNew {
		c.resubscribe()
	}
	return cn, isNew, nil
}
func (c *PubSub) putConn(cn *pool.Conn, err error) {
	c.base.putConn(cn, err, true)
}
func (c *PubSub) subscribe(redisCmd string, channels ...string) error {
	args := make([]interface{}, 1+len(channels))
	args[0] = redisCmd
	for i, channel := range channels {
		args[1+i] = channel
	}
	cmd := NewSliceCmd(args...)
	cn, _, err := c.conn()
	if err != nil {
		return err
	}
	cn.SetWriteTimeout(c.base.opt.WriteTimeout)
	err = writeCmd(cn, cmd)
	c.putConn(cn, err)
	return err
}