text: README ¶
  go-netutil
  netutil.RRDialer has the same interface of
  net.Dial.
  With this package, You can request to a specific IP address with priority as you like.
  In golang,
  net.LookupIP returns IP addresses after
  sortBy6724, that is defined in src/net/addrselect.go.
  Because of this, address for
  net.Dial might connect to a fixed ip address in some case.
  For example, source IP and destination IP are in the same local area network like "10.0.0.0/16" or "192.168.0.0/24".
  In my case, in a AWS VPC network,  always connect to a specific IP address of ELB from an EC2 instance.
  This will ruin the effects of DNS round robin.
  You can change the priority of each address with this package.
  netutil.DefaultRRDialer sort a list of address by random priority.
  Installation
  go get github.com/ReSTARTR/go-netutil
  Usage
  netutil.RRDialer
  netutil.DefaultRRDialer uses
  netutil.DefaultSort for sorting IP addresses.
  netutil.DefaultSort sorts IPs randomly.
  import ( "net/ "github.com/ReSTARTR/go-netutil" ) func main() { req, _ :=  " nil) client :=  Transport: & { Dial: netutil.DefaultRRDialer.Dial, }, } res, _ := client.Do(req) _ = res }
  You can set a specific
  netutil.RRDialer.Sort function.
  dialer := netutil.Dialer{ Sort: func(ips []net.IP) ([]net.IP) { sort.Sort(ByFoo(ips)) return ips }, } client :=  Transport: & { Dial: dialer.Dial, }, } client.Do(req)
  Contribution
  - Fork (
  - Create a feature branch
  - Commit your changes
  - Rebase your local changes against the master branch
  - Run test suite with the make test command and confirm that it passes
  - Create a new Pull Request
  Author
  Documentation ¶
  Index ¶
  Constants ¶
  This section is empty.
  Variables ¶
  var DefaultRRDialer = &RRDialer{ dialer: &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }, }
  DefaultRRDialer has a dialer that includes the same as DefaultTransport use
  Functions ¶
  func RandomSort ¶
  RandomSort sorts ips at random.
  Types ¶
  type RRDialer ¶
  RRDialer contains options for connection to an address with a specific IP.
  TODO: connection pool
  func (*RRDialer) Dial ¶
  Dial connects to the address with an specific IP on the named network.