package pkg import ( "errors" "strconv" "strings" ) type GTPProfile struct { ProfileCommon IngressMax int `json:"ingress_max"` //ingress-max 0 } func ParseGTP(raw string) (*GTPProfile, error) { p := new(GTPProfile) split := strings.Split(raw, "\n") if !strings.Contains(split[0], "ltm profile gtp") { return nil, errors.New("not a gtp profile") } p.ProfileCommon = parseCommon(raw) for _, line := range split { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "ingress-max": i, err := strconv.Atoi(f[1]) if err != nil { log.WithField("data", f[1]).Error(err.Error()) return nil, err } p.IngressMax = i } } return p, nil }