func ParsePropertiesFile()

in lambda/rapidcore/runtime_release.go [43:68]


func ParsePropertiesFile(path string) (map[string]string, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, fmt.Errorf("could not open %s: %w", path, err)
	}
	defer f.Close()

	pairs := make(map[string]string)

	s := bufio.NewScanner(f)
	for s.Scan() {
		if s.Text() == "" || strings.HasPrefix(s.Text(), "#") {
			continue
		}
		k, v, found := strings.Cut(s.Text(), "=")
		if !found {
			return nil, fmt.Errorf("could not parse key-value pair from a line: %s", s.Text())
		}
		pairs[k] = strings.Trim(v, "'\"")
	}
	if err := s.Err(); err != nil {
		return nil, fmt.Errorf("failed to read properties file: %w", err)
	}

	return pairs, nil
}