package vmware import ( "regexp" "strings" ) // ParseVMX parses the keys and values from a VMX file and returns // them as a Go map. func ParseVMX(contents string) map[string]string { results := make(map[string]string) lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"(.*?)"\s*$`) for _, line := range strings.Split(contents, "\n") { matches := lineRe.FindStringSubmatch(line) if matches == nil { continue } results[matches[1]] = matches[2] } return results }