In other Object Orient language, Override the exists function will be very 
easy.
But in golang. we can not easy override .

for example: I want to use the google/martian package.

https://github.com/google/martian/blob/master/proxy.go


func (p *Proxy) connect(req *http.Request) (*http.Response, net.Conn, 
error) {
if p.proxyURL != nil {
log.Debugf("martian: CONNECT with downstream proxy: %s", p.proxyURL.Host)

conn, err := net.Dial("tcp", p.proxyURL.Host)
if err != nil {
return nil, nil, err
}
pbw := bufio.NewWriter(conn)
pbr := bufio.NewReader(conn)

req.Write(pbw)
pbw.Flush()

res, err := http.ReadResponse(pbr, req)
if err != nil {
return nil, nil, err
}

return res, conn, nil
}

log.Debugf("martian: CONNECT to host directly: %s", req.URL.Host)

conn, err := net.Dial("tcp", req.URL.Host)
if err != nil {
return nil, nil, err
}

return proxyutil.NewResponse(200, nil, req), conn, nil
}


I can not override just one function . 

If you know how to override just one function. please let me know.

I do not want fork this big repository, just want import the package. and 
override one of the function.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to