From 92c9b81447649d5a8ed38ca79b71640c099e0243 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 21 Jun 2022 15:17:22 -0700 Subject: [PATCH] net: don't set netGo = true on Windows with no cgo Windows can call the C DNS lookup routines even without cgo, so don't force it to use the Go routines in that scenario. No test because the test requires building the tools with CGO_ENABLED=0. For #33097 Fixes #53490 Change-Id: I3595a68e788be0d3bbd1bbd431836aca20a7d757 Reviewed-on: https://go-review.googlesource.com/c/go/+/413458 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Bryan Mills Run-TryBot: Ian Lance Taylor Reviewed-by: Brad Fitzpatrick Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/net/cgo_stub.go | 2 -- src/net/netgo.go | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net/cgo_stub.go b/src/net/cgo_stub.go index cc84ca47ae..298d829f6f 100644 --- a/src/net/cgo_stub.go +++ b/src/net/cgo_stub.go @@ -8,8 +8,6 @@ package net import "context" -func init() { netGo = true } - type addrinfoErrno int func (eai addrinfoErrno) Error() string { return "" } diff --git a/src/net/netgo.go b/src/net/netgo.go index f91c91b614..75baa88035 100644 --- a/src/net/netgo.go +++ b/src/net/netgo.go @@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build netgo +// Default netGo to true if the netgo build tag is being used, or the +// C library DNS routines are not available. Note that the C library +// routines are always available on Windows. + +//go:build netgo || (!cgo && !windows) package net