host

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package host provides information about the host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IP

func IP() (ip string, err error)

IP returns the first non-loopback IP address of the host.

func Name

func Name() (name string, err error)

Name returns the host name reported by the kernel.

func PodName added in v0.12.0

func PodName() string

PodName returns the name of the pod this process runs in: POD_NAME, which the Kubernetes downward API sets, else the host name, which is the pod name in Kubernetes. It returns "" only when both are unknown.

func TimeZoneName added in v0.12.0

func TimeZoneName() string

TimeZoneName returns the IANA name of the host's local time zone, such as "Asia/Shanghai", or an empty string when the real name cannot be determined. An empty name means "unknown": callers comparing two hosts must treat it as a mismatch rather than as agreement. The answer is resolved once and reused.

There is no portable way to ask for this. The Go runtime resolves the local zone but never exposes its name — time.Local.String() reports the literal "Local" whenever TZ is unset, which is the normal state inside a container, so two hosts in different zones would look identical. Each platform therefore resolves the name the same way its own runtime resolves the zone: see localZoneName in timezone_unix.go and timezone_windows.go.

Types

This section is empty.

Jump to

Keyboard shortcuts

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