-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
Go 1.26 introduces four more Dial functions in package net (#49097), which means we now have a complicated combination of old and new ways to represent addresses and dial. What are the best practices today? At a minimum, the documentation should give guidance on how to navigate this. Is there an opportunity for a modernizer to automatically drive code toward the latest best practices?
For dialing, we now have
func Dial(network, address string) (Conn, error)
func DialTimeout(network, address string, timeout time.Duration) (Conn, error)
func DialIP(network string, laddr, raddr *IPAddr) (*IPConn, error)
func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPConn, error)
func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPConn, error)
func DialUnix(network string, laddr, raddr *UnixAddr) (*UnixConn, error)
func (*Dialer) Dial(network, address string) (Conn, error)
func (*Dialer) DialContext(ctx context.Context, network, address string) (Conn, error)
func (*Dialer) DialIP(ctx context.Context, network string, laddr, raddr netip.Addr) (*IPConn, error)
func (*Dialer) DialTCP(ctx context.Context, network string, laddr, raddr netip.AddrPort) (*TCPConn, error)
func (*Dialer) DialUDP(ctx context.Context, network string, laddr, raddr netip.AddrPort) (*UDPConn, error)
func (*Dialer) DialUnix(ctx context.Context, network string, laddr, raddr *UnixAddr) (*UnixConn, error)For addresses, we now have
string
// Package net
type Addr interface { ... }
type IP []byte
type IPAddr struct {IP; string}
type TCPAddr struct {IP; int; string}
type UDPAddr struct {IP; int; string}
type UnixAddr struct {string; string}
// Package net/netip
type Addr struct { ... }
type AddrPort struct { ... }mateusz834
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.