...

Source file src/net/main_conf_test.go

Documentation: net

		 1  // Copyright 2015 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  //go:build !js && !plan9 && !windows
		 6  // +build !js,!plan9,!windows
		 7  
		 8  package net
		 9  
		10  // forceGoDNS forces the resolver configuration to use the pure Go resolver
		11  // and returns a fixup function to restore the old settings.
		12  func forceGoDNS() func() {
		13  	c := systemConf()
		14  	oldGo := c.netGo
		15  	oldCgo := c.netCgo
		16  	fixup := func() {
		17  		c.netGo = oldGo
		18  		c.netCgo = oldCgo
		19  	}
		20  	c.netGo = true
		21  	c.netCgo = false
		22  	return fixup
		23  }
		24  
		25  // forceCgoDNS forces the resolver configuration to use the cgo resolver
		26  // and returns a fixup function to restore the old settings.
		27  // (On non-Unix systems forceCgoDNS returns nil.)
		28  func forceCgoDNS() func() {
		29  	c := systemConf()
		30  	oldGo := c.netGo
		31  	oldCgo := c.netCgo
		32  	fixup := func() {
		33  		c.netGo = oldGo
		34  		c.netCgo = oldCgo
		35  	}
		36  	c.netGo = false
		37  	c.netCgo = true
		38  	return fixup
		39  }
		40  

View as plain text