feat(netx): 自 go-hua/common 迁入本机网络信息工具并独立成包
- 枚举 IPv4 地址与 MAC 地址(过滤回环与虚拟网卡),附测试、例程与 README
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// netx 包示例:本机网络信息(IPv4 地址列表、MAC 地址列表)
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.zeroonesoft.cn/golib/zogo/netx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ips, err := netx.GetLocalIp()
|
||||
fmt.Println("本机 IPv4:", ips, "错误:", err)
|
||||
|
||||
macs, err := netx.GetLocalMac()
|
||||
fmt.Println("本机 MAC:", macs, "错误:", err)
|
||||
}
|
||||
Reference in New Issue
Block a user