system

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetOperatingSystem = func() string {
	return runtime.GOOS
}

Wrapper on runtime.GOOS, that tells you current OS name

Functions

func GetInMemorySizeInBytes

func GetInMemorySizeInBytes(v interface{}) (int64, error)

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

func GetPrimaryNetworkInterface() (*net.Interface, net.Addr, error)

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.

func IsWindows

func IsWindows() bool

IsWindows returns true if the current operating system is Windows.

It checks the runtime GOOS value and can be used to write platform-specific code when behavior needs to vary between Windows and UNIX-like systems.

func LoadTLSCredentials

func LoadTLSCredentials(certFile, keyFile, caFile string) (*tls.Config, error)

LoadTLSCredentials loads TLS credentials from cert, key, and CA files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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