package pkg import "strings" // ProfileCommon : shared profile entries type ProfileCommon struct { AppService string `json:"app_service,omitempty"` DefaultsFrom string `json:"defaults_from,omitempty"` Description string `json:"description,omitempty"` Partition string `json:"partition,omitempty"` } func parseCommon(raw string) (d ProfileCommon) { for _, line := range strings.Split(raw, "\n") { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "app-service": d.AppService = strings.Join(f[1:], " ") case "defaults-from": d.DefaultsFrom = strings.Join(f[1:], " ") case "description": d.Description = strings.Join(f[1:], " ") case "partition": d.Partition = strings.Join(f[1:], " ") } } return } func parseBool(s string) bool { switch strings.ToLower(s) { case "yes": return true case "enabled": return true case "true": return true } return false }