dosrmo0442 2019-02-27 00:02
浏览 466
已采纳

Golang:获取系统解析器的DNS服务器列表

In Ruby I can get the list of dns servers like this:

require 'resolv'
Resolv::DNS::Config.default_config_hash[:nameserver]

How to do the same in Go?

  • 写回答

1条回答 默认 最新

  • doulu3865 2019-02-27 14:47
    关注

    The Resolver type in the net package lets you resolve DNS names but it doesn't seem to export the DNS servers it uses.

    Ruby parses /etc/resolv.conf so I guess you'll have to do that yourself or see if you can find a package that does it for you.

    Update: I made a small library to do sort of the same as Ruby's DNS class. Hope it helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 chatgpt网页版侧边栏和模型切换点击没反应怎么办
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas