github.com/laof/lite-speed-test@v0.0.0-20230930011949-1f39b7037845/dns/resolver_test.go (about)

     1  package dns
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestRequest(t *testing.T) {
     9  	c := Config{
    10  		Main: []NameServer{
    11  			{
    12  				Net:  "udp",
    13  				Addr: "8.8.8.8:53",
    14  			},
    15  			{
    16  				Net:  "udp",
    17  				Addr: "223.5.5.5:53",
    18  			},
    19  		},
    20  	}
    21  	r := NewResolver(c)
    22  	// TODO: resolve ipv4
    23  	ip, err := r.ResolveIP("www.github.com")
    24  	if err != nil {
    25  		t.Error(err)
    26  	}
    27  	fmt.Printf("ip: %s\n", ip.String())
    28  }