package asaModels import ( "regexp" "strings" ) var startupErrRE = regexp.MustCompile(`(?is)(\w+):\s+(.*)\n(.*)`) type ( Startup struct { Errors []Error `json:"errors"` } Error struct { Type string `json:"type"` Message string `json:"message"` Line string `json:"line"` } ) func (i *Startup) Parse(s string) error { for _, r := range strings.Split(strings.Replace(s, "\"", "'", -1), "'\n") { for _, match := range startupErrRE.FindAllStringSubmatch(r, -1) { if len(match) == 0 { continue } i.Errors = append(i.Errors, Error{ Type: match[1], Message: strings.Replace(match[2], "\n", "", -1), Line: match[3], }) } } return nil }