jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.62k stars 174 forks source link

Can't get MAC address in macOS Monterey, netFillInfo not implemented on darwin #370

Open sonvirgo opened 1 month ago

sonvirgo commented 1 month ago

Can't get MAC address in macOS Monterey. Also Disks not return any Serial number.

Error getting network info: netFillInfo not implemented on darwin

Screen Shot 2024-07-09 at 7 44 42 AM

jaypipes commented 1 month ago

Hi @sonvirgo thank you for the issue. As noted in the README, we only have partial support for MacOS, unfortunately. We do not support network discovery for MacOS currently.

As for the Disk missing serial number information, can you please run the following and let us know what you get?

package main

import (
    "fmt"

    "github.com/jaypipes/ghw"
)

func main() {
    block, err := ghw.Block()
    if err != nil {
        fmt.Printf("Error getting block storage info: %v", err)
    }

    fmt.Printf("%v\n", block)

    for _, disk := range block.Disks {
        fmt.Printf(" %v\n", disk)
        if disk.SerialNumber != "" {
            fmt.Print("No serial number")
        } else {
            fmt.Printf("Serial number: %s\n", disk.SerialNumber)
        }
        for _, part := range disk.Partitions {
            fmt.Printf("  %v\n", part)
        }
    }
}
sonvirgo commented 1 month ago

Hi @sonvirgo thank you for the issue. As noted in the README, we only have partial support for MacOS, unfortunately. We do not support network discovery for MacOS currently.

As for the Disk missing serial number information, can you please run the following and let us know what you get?

package main

import (
  "fmt"

  "github.com/jaypipes/ghw"
)

func main() {
  block, err := ghw.Block()
  if err != nil {
      fmt.Printf("Error getting block storage info: %v", err)
  }

  fmt.Printf("%v\n", block)

  for _, disk := range block.Disks {
      fmt.Printf(" %v\n", disk)
      if disk.SerialNumber != "" {
          fmt.Print("No serial number")
      } else {
          fmt.Printf("Serial number: %s\n", disk.SerialNumber)
      }
      for _, part := range disk.Partitions {
          fmt.Printf("  %v\n", part)
      }
  }
}

Thank you. Here the result

Unknown block device
No disk

Screen Shot 2024-07-10 at 10 03 12 AM

I build the app with CGO_ENABLE-0 , does this affect the ghw?