package main import ( "encoding/json" "fmt" "log" ) func getDisks() *Devices { rawout := execSystem("lsblk", "-dJ", "-I 8") if rawout == nil { log.Fatal("") } var parsed Devices // decoding country1 struct // from json format err := json.Unmarshal(rawout, &parsed) if err != nil { // if error is not nil // print error fmt.Println(err) } return &parsed } type BlockDevice struct { Name string `json:"name"` Size string `json:"size"` Type string `json:"type"` } type Devices struct { Blockdevices []BlockDevice `json:"blockdevices"` }