Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GetOperatingSystem = func() string { return runtime.GOOS }
Wrapper on runtime.GOOS, that tells you current OS name
Functions ¶
func GetInMemorySizeInBytes ¶
GetInMemorySizeInBytes estimates the in-memory size of a Go value.
It handles primitive types (int, bool, float), strings, slices, maps, structs, and pointers recursively. For complex types like slices and maps, the size calculation includes both metadata (headers) and element data.
Returns:
- int64: Total estimated size in bytes.
- error: If the type is unsupported.
Note: This is an approximate estimation and may differ from actual runtime memory usage, especially for types with internal optimizations.
func GetPrimaryNetworkInterface ¶
GetPrimaryNetworkInterface returns the first non-loopback, active network interface and one of its associated IP addresses.
It scans all available network interfaces and selects the first one that is "up" (running) and not a loopback interface. From there, it picks a usable IPv4 or IPv6 address that is not unspecified or loopback.
Returns:
- *net.Interface: Pointer to the selected network interface.
- net.Addr: The corresponding IP address.
- error: If no suitable interface is found or an error occurs.
This function is useful for determining the primary external-facing IP address of the machine without needing external internet connections.
func IsDarwin ¶
func IsDarwin() bool
IsDarwin returns true if the current operating system is macOS (Darwin).
This is useful when differentiating logic between macOS and other platforms like Linux or Windows.
func IsLinux ¶
func IsLinux() bool
IsLinux returns true if the current operating system is Linux.
It uses the GOOS environment value to detect the platform at runtime, allowing platform-specific code branching if needed.
Types ¶
This section is empty.