go程序中的dns解析方式优先级

Sun 12 October 2025

golang有两种域名解析方法:内置go解析器和基于cgo的系统解析器。

默认情况下用的是内置解析,如果你想指定使用cgo解析器,可以build的时候指定。

export GODEBUG=netdns=go    # force pure Go resolver
export GODEBUG=netdns=cgo   # force cgo resolver

const (
    // hostLookupCgo means defer to cgo.
    hostLookupCgo      hostLookupOrder = iota
    hostLookupFilesDNS                 // files first
    hostLookupDNSFiles                 // dns first
    hostLookupFiles                    // only files
    hostLookupDNS                      // only DNS
)

var lookupOrderName = map[hostLookupOrder]string{
    hostLookupCgo:      "cgo",
    hostLookupFilesDNS: "files,dns",
    hostLookupDNSFiles: "dns,files",
    hostLookupFiles:    "files",
    hostLookupDNS:      "dns",
}

根据操作系统的不同,使用的解析策略也会略有不同

当 前 系 统 如 果 是 linux 并 且 不 存 在 /etc/nsswitch.conf 文 件 的 时 候 , 会 直 接 返 回 dnsfiles 的 顺 序 , 这 个 是 参 考 了 glibc 的 实 现

Category: 数字生活


searchparams

Wed 24 September 2025

那 么 该 如 何 解 析 参 数 呢 ? 参 数 已 经 在 实 例 的 searchparams 属 性 中 , 这 个 属 性 也 是 URLSearchParams 的 实 例 。

const uu = new URL( “/api?a=18b=2&ccccc「 , “https://example.com 「) ; “ava2crlpt const { SearchParams } = uu; sSearchParams。get …

Category: 数字生活

Read More

STEAMDB

Wed 24 September 2025

steamDB是一个第三方steam数据库网站,在该网站上能够查询到steam游戏的区域信息,打折信息, 价格变动信息,以及steam游戏激活码等信息。

Category: 数字生活

Read More

在 Docker 中 的 “ 完 整 “Ubuntu 开 发 环 境 容 器

Wed 24 September 2025

@ @ @ wusiyu@9dab0b085b97: ~ [ 】 Reached target MuLti-User System. [ ]】 Reached target Graphtcal Interface.

Starting Update UTMP about System Runlevel Changes … [ ] Finished Update UTMP about System RunlLevel Changes.

Ubuntu 28.84.2 LTS 9dab8b885b97 console

9dab8b885b97 login: wusiyu Passmord : Welcome to Ubuntu 28.84.2 LTS CGNU/Linux 5.13.9-2880.fc34.x86_64 x86_64 …

Category: 数字生活

Read More

笔 记

Wed 24 September 2025

这 些 笔 记 App? 至 少 我 不 需 要 , 因 为 我 有 自 建 博 客 。

让 我 们 思 考 一 些 灵 魂 拷 问 “:

  1. 谁 拥 有 数 据 2 这 些 App 以 什 么 格 式 存 储 数 据 ? 万 一 …

Category: 数字生活

Read More

脚 本 获 取 TLS/SSL 证 书 失 效 日 期

Wed 24 September 2025

从 https://Wwww.cyberciti.biz/fad/find-check-tls-ssl-certificate-expiry-date-from-linux- unix/ 上 看 到 的 使 用 小 脚 本

下 面 这 个 脚 本 能 够 获 取 TLS/SSL 证 书 的 生 效 日 期 和 失 效 日 期

exec 2>/dev/nuLt openssl s_client -servername ${SERVER_NAME} -connect …

Category: 数字生活

Read More
Page 1 of 4

Next »