Skip to content

Instantly share code, notes, and snippets.

@miekg
Created July 19, 2022 13:34
Show Gist options
  • Save miekg/8e0a435f4f3b15852ed7ccd34424efd1 to your computer and use it in GitHub Desktop.
Save miekg/8e0a435f4f3b15852ed7ccd34424efd1 to your computer and use it in GitHub Desktop.
package dns
import (
"fmt"
"net"
"testing"
)
// Test function to test how the API feels.
func TestDNS(t *testing.T) {
rr := new(A)
rr.Hdr.Name.Set("example.net.")
rr.Hdr.Class.Set(ClassINET)
rr.Hdr.TTL.Set(15)
rr.SetData(0, net.IPv4allrouter)
fmt.Printf("%s %s\n", rr.Hdr.String(), rr.String()) // example.net. 15 IN A 224.0.0.2
fmt.Printf("%#v %#v\n", rr.Hdr.GoString(), rr.String()) // "07example03net00 15 IN" "A\t224.0.0.2"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment