Documentation
¶
Overview ¶
Package machine provides utilities to generate unique machine IDs for licensing and identification purposes. The generated IDs are based on hardware characteristics that are difficult for users to modify.
The package collects hardware information such as:
- CPU information (processor ID, features)
- Motherboard serial number and UUID
- Network interface MAC addresses
- System UUID from BIOS/UEFI
- Disk serial numbers
These hardware identifiers are combined and hashed to create a unique machine ID that remains consistent across reboots and software changes, but will change if significant hardware modifications are made to the system.
Example usage:
// Generate machine ID with default settings
id, err := machine.New().WithCPU().WithMotherboard().WithSystemUUID().WithMAC().WithDisk().ID()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Machine ID: %s\n", id)
// Generate machine ID with custom options
id, err := machine.New().WithSalt("my-app-salt").WithCPU().WithSystemUUID().ID()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Machine ID: %s\n", id)
// Generate VM-friendly machine ID
id, err := machine.New().VMFriendly().WithSalt("my-app").ID()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Machine ID: %s\n", id)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.