func NewDecoder(rd io.Reader) *Decoder { brd, ok := rd.(bufReader) if !ok { brd = bufio.NewReader(rd) } return &Decoder{ R: brd, DecodeMapFunc: decodeMap, } }
func newConnFunc(dial func() (net.Conn, error)) func() (*conn, error) { return func() (*conn, error) { netcn, err := dial() if err != nil { return nil, err } cn := &conn{ cn: netcn, } cn.rd = bufio.NewReader(cn) return cn, nil } }
func newConnFunc(opt *Options) func() (*conn, error) { return func() (*conn, error) { netcn, err := dial(opt) if err != nil { return nil, err } cn := &conn{ opt: opt, cn: netcn, buf: newBuffer(), } cn.br = bufio.NewReader(cn) if err := cn.Startup(); err != nil { return nil, err } return cn, nil } }