Esempio n. 1
0
func NewDecoder(rd io.Reader) *Decoder {
	brd, ok := rd.(bufReader)
	if !ok {
		brd = bufio.NewReader(rd)
	}
	return &Decoder{
		R:             brd,
		DecodeMapFunc: decodeMap,
	}
}
Esempio n. 2
0
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
	}
}
Esempio n. 3
0
File: conn.go Progetto: rsrsps/pg
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
	}
}