Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LocalIPv4 ¶
func LocalIPv4() string
LocalIPv4 returns the first non-loopback IPv4 address of the local machine.
The result is cached after the first call using sync.Once, so subsequent calls are fast. If no non-loopback IPv4 address is found, "0.0.0.0" is returned.
Note:
- Only IPv4 addresses are considered; IPv6 addresses are ignored.
- The result does not update if the network interfaces change after the first call.
- For more robust use, consider returning (string, error) to handle the case where no valid IPv4 address is available.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.