forked from denisbrodbeck/machineid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (46 loc) · 1013 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Package main provides the command line app for reading the unique machine id of most OSs.
//
// Usage: machineid [options]
//
// Options:
// --appid <AppID> Protect machine id by hashing it together with an app id.
//
// Try:
// machineid
// machineid --appid MyAppID
package main
import (
"flag"
"fmt"
"log"
"github.com/denisbrodbeck/machineid"
)
const usageStr = `
Usage: machineid [options]
Options:
--appid <AppID> Protect machine id by hashing it together with an app id.
Try:
machineid
machineid --appid MyAppID
`
func usage() {
log.Fatalln(usageStr)
}
func main() {
var appID string
flag.StringVar(&appID, "appid", "", "Protect machine id by hashing it together with an app id.")
log.SetFlags(0)
flag.Usage = usage
flag.Parse()
var id string
var err error
if appID != "" {
id, err = machineid.ProtectedID(appID)
} else {
id, err = machineid.ID()
}
if err != nil {
log.Fatalf("Failed to read machine id with error: %s\n", err)
}
fmt.Println(id)
}