github.com/m10x/go/src@v0.0.0-20220112094212-ba61592315da/net/netgo_unix_test.go (about)

     1  // Copyright 2013 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 (!cgo || netgo) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris)
     6  
     7  package net
     8  
     9  import (
    10  	"context"
    11  	"testing"
    12  )
    13  
    14  func TestGoLookupIP(t *testing.T) {
    15  	defer dnsWaitGroup.Wait()
    16  	host := "localhost"
    17  	ctx := context.Background()
    18  	_, err, ok := cgoLookupIP(ctx, "ip", host)
    19  	if ok {
    20  		t.Errorf("cgoLookupIP must be a placeholder")
    21  	}
    22  	if err != nil {
    23  		t.Error(err)
    24  	}
    25  	if _, err := DefaultResolver.goLookupIP(ctx, "ip", host); err != nil {
    26  		t.Error(err)
    27  	}
    28  }