package pkg import ( "errors" "strings" ) type StreamProfile struct { ProfileCommon Source string `json:"source"` Target string `json:"target"` } func ParseStream(raw string) (*StreamProfile, error) { p := new(StreamProfile) split := strings.Split(raw, "\n") if !strings.Contains(split[0], "ltm profile stream") { return nil, errors.New("not an stream profile") } p.ProfileCommon = parseCommon(raw) for _, line := range split { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "target": p.Target = strings.Join(f[1:], " ") case "source": p.Source = strings.Join(f[1:], " ") } } return p, nil }