exec.Command return different values between go and commandline

Hello, i am try to get a json output from the commandline but it seems the result is not valid.\

output, err := exec.Command("/usr/sbin/system_profiler", "SPHardwareDataType", "-json").CombinedOutput()
    if err != nil {
        log.Println("/usr/sbin/system_profiler SPHardwareDataType -json", err, output)
    }
    fmt.Println(string(output))

This will return this data:

 {
  "SPHardwareDataType" : [
    {
      "_name" : "hardware_overview",
      "activation_lock_status" : "activation_lock_disabled",
      "cpu_type" : "Unknown",
      "current_processor_speed" : "2,4 GHz",
      "l2_cache" : "8 MB",
      "machine_model" : "MacBookAir10,1",
      "machine_name" : "MacBook Air",
      "number_processors" : 8,
      "packages" : 1,
      "physical_memory" : "16 GB",
      "platform_UUID" : "6BF86BB5-A724-5D99-BC31-8C2E851C264E",
      "provisioning_UDID" : "6BF86BB5-A724-5D99-BC31-8C2E851C264E",
      "serial_number" : "C02DVC27Q6LR"
    }
  ]
}


If i run this command directly from the commandline the output looks like this:

{
  "SPHardwareDataType" : [
    {
      "_name" : "hardware_overview",
      "activation_lock_status" : "activation_lock_disabled",
      "boot_rom_version" : "7429.41.5",
      "chip_type" : "Apple M1",
      "machine_model" : "MacBookAir10,1",
      "machine_name" : "MacBook Air",
      "number_processors" : "proc 8:4:4",
      "os_loader_version" : "7429.41.5",
      "physical_memory" : "16 GB",
      "platform_UUID" : "6BF86BB5-A724-5D99-BC31-8C2E851C264E",
      "provisioning_UDID" : "00008103-001538C026E2001E",
      "serial_number" : "C02DVC27Q6LR"
    }
  ]
}

May be some of you knows if there exist any restrictions from system side. Thanks for help

go version go version go1.17.6 darwin/amd64

go version go version go1.17.6 darwin/arm64

Wrong installed packaged was the root cause for this problem (darwin/amd64)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.