How to unit test net.Resolver?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • go-mockdns

    Boilerplate for testing of code involving DNS lookups, including unholy hacks to redirect net.Lookup* calls.

  • dns

    DNS library in Go

  • You can do the same with net.Resolver, either by just setting it's Dial function (and PreferGo=true). You can use https://pkg.go.dev/golang.org/x/net/dns/dnsmessage or https://github.com/miekg/dns to implement an in-process server, either over TCP/UDP or skipping real networking completely, just like you can do with https://golang.org/pkg/net/http/httptest

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts