github.com/StingNevermore/go@v0.0.0-20180120041312-3810f5bfed72/src/net/main_conf_test.go (about)

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