10 "github.com/denisbrodbeck/machineid"
17 fallbackId = "unknown"
20func getDistinctId() string {
21 if id, err := machineid.ProtectedID(hashKey); err == nil {
24 if macAddr, err := getMacAddr(); err == nil {
25 return hashString(macAddr)
30func getMacAddr() (string, error) {
31 interfaces, err := net.Interfaces()
35 for _, iface := range interfaces {
36 if iface.Flags&net.FlagUp != 0 && iface.Flags&net.FlagLoopback == 0 && len(iface.HardwareAddr) > 0 {
37 if addrs, err := iface.Addrs(); err == nil && len(addrs) > 0 {
38 return iface.HardwareAddr.String(), nil
42 return "", fmt.Errorf("no active interface with mac address found")
45func hashString(str string) string {
46 hash := hmac.New(sha256.New, []byte(str))
47 hash.Write([]byte(hashKey))
48 return hex.EncodeToString(hash.Sum(nil))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list