network

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 2 Imported by: 0

README

Network (网络)

提供网络相关的实用函数。

API

GetInternalNetworkIp
  • 签名: func GetInternalNetworkIp() string
  • 描述: 获取本机在局域网中的 IP 地址。通过建立 UDP 伪连接(不发送数据)来自动选择合适的路由接口 IP。

示例

import (
    "fmt"
    "github.com/fireflycore/go-utils/network"
)

func main() {
    ip := network.GetInternalNetworkIp()
    fmt.Println("Local IP:", ip)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInternalNetworkIp

func GetInternalNetworkIp() string

GetInternalNetworkIp 获取本机在局域网中的 IP 地址 原理:通过建立 UDP 伪连接(不发送数据)来自动选择合适的路由接口 IP 返回: 字符串形式的 IP 地址(如 "192.168.1.5")。如果获取失败,返回 "127.0.0.1"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL