github.com/Andyfoo/golang/x/net@v0.0.0-20190901054642-57c1bf301704/proxy/direct.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package proxy 6 7 import ( 8 "context" 9 "net" 10 ) 11 12 type direct struct{} 13 14 // Direct implements Dialer by making network connections directly using net.Dial or net.DialContext. 15 var Direct = direct{} 16 17 var ( 18 _ Dialer = Direct 19 _ ContextDialer = Direct 20 ) 21 22 // Dial directly invokes net.Dial with the supplied parameters. 23 func (direct) Dial(network, addr string) (net.Conn, error) { 24 return net.Dial(network, addr) 25 } 26 27 // DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters. 28 func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { 29 var d net.Dialer 30 return d.DialContext(ctx, network, addr) 31 }