{"record":{"id":"489b5af4f18d4f9f","repo":"jeessy2/ddns-go","slug":"s-v","errorCode":null,"errorMessage":"找不到网卡 %s: %v","messagePattern":"找不到网卡 (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/http_client_util.go","lineNumber":101,"sourceCode":"\tExpectContinueTimeout: 1 * time.Second,\n}\n\n// insecureSkipVerify 全局TLS验证跳过标志\nvar insecureSkipVerify bool\n\n// CreateHTTPClient Create Default HTTP Client\nfunc CreateHTTPClient() *http.Client {\n\treturn &http.Client{\n\t\tTimeout:   30 * time.Second,\n\t\tTransport: defaultTransport,\n\t}\n}\n\n// GetLocalAddrFromInterface 根据网卡名称获取本地IP地址\nfunc GetLocalAddrFromInterface(ifaceName string) (string, error) {\n\tiface, err := net.InterfaceByName(ifaceName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"找不到网卡 %s: %v\", ifaceName, err)\n\t}\n\taddrs, err := iface.Addrs()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"获取网卡 %s 地址失败: %v\", ifaceName, err)\n\t}\n\tfor _, addr := range addrs {\n\t\tif ipNet, ok := addr.(*net.IPNet); ok && ipNet.IP.IsGlobalUnicast() {\n\t\t\treturn ipNet.IP.String(), nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"网卡 %s 没有可用的单播地址\", ifaceName)\n}\n\n// CreateHTTPClientWithInterface 创建绑定指定网卡的HTTP客户端\nfunc CreateHTTPClientWithInterface(ifaceName string) *http.Client {\n\tif ifaceName == \"\" {\n\t\treturn CreateHTTPClient()\n\t}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/util/http_client_util.go#L83-L119","documentation":"GetLocalAddrFromInterface looks up the interface by name with net.InterfaceByName; when no interface with that name exists on the host, the OS lookup fails and this error wraps that failure with a Chinese message meaning 'network interface <name> not found'. It is used by CreateHTTPClientWithInterface to resolve the bind IP for the interface-bound HTTP client.","triggerScenarios":"Calling GetLocalAddrFromInterface(name) or CreateHTTPClientWithInterface(name) with a name that does not match any interface on the machine (typos, Windows names like '以太网' vs Linux 'eth0', renamed interfaces).","commonSituations":"Config written for one machine deployed to another with different NIC names (eth0 vs ens33 vs en0); container names differ from host names; interface renamed by systemd predictable naming; missing netdev (VPN not up).","solutions":["List actual interface names (net.Interfaces(), or `ip link`) and correct the configured name","Make the interface name configurable per environment instead of hardcoding","Note CreateHTTPClientWithInterface already falls back to the default client on this error — check logs for '绑定网卡失败' to confirm the fallback happened","Create the missing interface (bring up the VPN/tunnel) if the app expects it"],"exampleFix":"// before\nclient := util.CreateHTTPClientWithInterface(\"eth0\") // host uses ens33\n// after\nifaces, _ := net.Interfaces() // inspect names, then:\nclient := util.CreateHTTPClientWithInterface(\"ens33\")","handlingStrategy":"validation","validationCode":"func ifaceExists(name string) bool {\n\t_, err := net.InterfaceByName(name)\n\treturn err == nil\n}\n// guard: if !ifaceExists(cfg.Interface) { fail fast or use default client }","typeGuard":null,"tryCatchPattern":"func safeClientWithInterface(name string) *http.Client {\n\tif _, err := net.InterfaceByName(name); err != nil {\n\t\tlog.Printf(\"interface %q not found: %v; using default client\", name, err)\n\t\treturn util.CreateHTTPClient()\n\t}\n\treturn util.CreateHTTPClientWithInterface(name)\n}","preventionTips":["Discover interface names at runtime (net.Interfaces()) instead of hardcoding","Use per-environment configuration for the interface name (host NIC names differ: eth0/ens33/en0)","Fail fast at startup if the configured interface does not exist, rather than silently falling back","Remember CreateHTTPClientWithInterface silently falls back to the default client — watch logs for '绑定网卡失败'"],"tags":["network","interface-not-found","go","configuration"],"backgroundTag":"interface-not-found","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}