package pkg import ( "regexp" "strings" ) type ( SysSoftware struct { Software []Volumes `json:"software"` } Volumes struct { Volume *string `json:"volume"` Product *string `json:"product"` Version *string `json:"version"` Build *string `json:"build"` Active bool `json:"active"` Status *string `json:"status"` } ) func ParseSysSoftware(s string) SysSoftware { var sys SysSoftware for _, v := range regexp.MustCompile(`(?i)(HD\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*?)\n+`).FindAllStringSubmatch(s, -1) { sys.Software = append(sys.Software, Volumes{ Volume: &v[1], Product: &v[2], Version: &v[3], Build: &v[4], Active: softActive(v[5]), Status: &v[6], }) } return sys } func softActive(a string) bool { if strings.Contains(a, "yes") { return true } return false }