zmodyfikuj ten kod o błąd: exit status 0x80041017 package main import ( "fmt" "log"…
- User
zmodyfikuj ten kod o błąd: exit status 0x80041017
package main
import ( "fmt" "log" "os/exec" "strings"
)
func main() { cmd := exec.Command("cmd", "/c", "wmic", "diskdrive", "get", "model,serialnumber,firmwareversion,status")
output, err := cmd.Output() if err != nil { log.Fatal(err) } smartInfo := parseWmicOutput(string(output)) displaySmartInfo(smartInfo)}
type SmartInfo struct { Model string SerialNum string FirmwareVer string // Dodaj inne dane SMART, ktore chcesz wyswietlic }
func parseWmicOutput(output string) SmartInfo { lines := strings.Split(output, "\n") info := SmartInfo{}
for _, line := range lines { if line == "" || line == "Model SerialNumber FirmwareVersion Status" { continue } fields := strings.Fields(line) info.Model = fields[0] info.SerialNum = fields[1] info.FirmwareVer = fields[2] // Dodaj inne przypadki, aby sparsowac inne dane SMART break } return info}
func displaySmartInfo(info SmartInfo) { fmt.Println("Model: ", info.Model) fmt.Println("Serial Number: ", info.SerialNum) fmt.Println("Firmware Version: ", info.FirmwareVer) // Dodaj inne wyswietlane dane SMART // Pamietaj, zeby wielkosc liter w polach odpowiadala polom struktury SmartInfo }
- Assistant
package main
import ( "fmt" "log" "os/exec" "strings" )
func main() { cmd := exec.Command("cmd", "/c", "wmic", "diskdrive", "get", "model,serialnumber,firmwareversion,status")
output, err := cmd.CombinedOutput() if err != nil { log.Fatal(err) } smartInfo := parseWmicOutput(string(output)) displaySmartInfo(smartInfo)}
type SmartInfo struct { Model string SerialNum string FirmwareVer string // Dodaj inne dane SMART, ktore chcesz wyswietlic }
func parseWmicOutput(output string) SmartInfo { lines := strings.Split(output, "\n") info := SmartInfo{}