From be4eb6a39e14952c0836a26cc111ddf41532a838 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 8 Aug 2023 21:22:26 -0700 Subject: [PATCH] derp, net/dns/recursive: use Go 1.21 min Updates #8419 Signed-off-by: Brad Fitzpatrick --- derp/derp.go | 9 +-------- net/dns/recursive/recursive.go | 8 -------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/derp/derp.go b/derp/derp.go index c1ae5b593..478c7d405 100644 --- a/derp/derp.go +++ b/derp/derp.go @@ -199,7 +199,7 @@ func readFrame(br *bufio.Reader, maxSize uint32, b []byte) (t frameType, frameLe return 0, 0, fmt.Errorf("frame header size %d exceeds reader limit of %d", frameLen, maxSize) } - n, err := io.ReadFull(br, b[:minUint32(frameLen, uint32(len(b)))]) + n, err := io.ReadFull(br, b[:min(frameLen, uint32(len(b)))]) if err != nil { return 0, 0, err } @@ -233,10 +233,3 @@ func writeFrame(bw *bufio.Writer, t frameType, b []byte) error { } return bw.Flush() } - -func minUint32(a, b uint32) uint32 { - if a < b { - return a - } - return b -} diff --git a/net/dns/recursive/recursive.go b/net/dns/recursive/recursive.go index 98bbaaf31..1314cdbc3 100644 --- a/net/dns/recursive/recursive.go +++ b/net/dns/recursive/recursive.go @@ -14,7 +14,6 @@ import ( "time" "github.com/miekg/dns" - "golang.org/x/exp/constraints" "golang.org/x/exp/slices" "tailscale.com/envknob" "tailscale.com/net/netns" @@ -484,13 +483,6 @@ func (r *Resolver) resolveRecursive( return nil, 0, ErrNoResponses } -func min[T constraints.Ordered](a, b T) T { - if a < b { - return a - } - return b -} - // queryNameserver sends a query for "name" to the nameserver "nameserver" for // records of type "qtype", trying both UDP and TCP connections as // appropriate.