Documentation
¶
Overview ¶
Package machineid provides a way to get a unique identifier for the current machine without using any internal hardware IDs. As a result, it doesn't require any special permissions to run and works in unprivileged containers as well.
The returned ID is generally stable for the OS installation and usually stays the same after updates or hardware changes.
Caveat: Image-based environments usually have the same machine-id (perfect clones). Linux users can generate a new id with `dbus-uuidgen` and put the id into `/var/lib/dbus/machine-id` and `/etc/machine-id`.
Windows users can use the `sysprep` toolchain to create images, which produce valid images ready for distribution.
This is based on https://github.com/denisbrodbeck/machineid which is no longer maintained.
Example ¶
package main
import (
"fmt"
machineid "github.com/columnar-tech/machine-id"
)
func main() {
id, err := machineid.ID()
if err != nil {
panic(err)
}
fmt.Println(id)
}
Output:
Example (ProtectedID) ¶
package main
import (
"fmt"
machineid "github.com/columnar-tech/machine-id"
)
func main() {
id, err := machineid.ProtectedID()
if err != nil {
panic(err)
}
fmt.Println(id)
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ID ¶
ID returns the platform specific machine id of the current host OS. Consider the returned id as "confidential" information and consider using ProtectedID() instead for privacy preserving usage.
func ProtectedID ¶
ProtectedID returns an HMAC-SHA256 hashed version of the machine ID using a fixed key. This is a privacy preserving way to use the machine ID as it is not reversible and the same on every call on the same machine.
Types ¶
This section is empty.