1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

CHORE: linting (#2176)

This commit is contained in:
Tom Limoncelli
2023-03-15 18:35:34 -04:00
committed by GitHub
parent fb6a79ab6f
commit 81054e72c5
3 changed files with 23 additions and 14 deletions

View File

@@ -34,19 +34,18 @@ var delimiterRegex = regexp.MustCompile(`(?m)^---\n`)
func parseFrontMatter(content string) (map[string]interface{}, string, error) {
delimiterIndices := delimiterRegex.FindAllStringIndex(content, 2)
if len(delimiterIndices) > 0 {
startIndex := delimiterIndices[0][0]
endIndex := delimiterIndices[1][0]
yamlString := content[startIndex+4 : endIndex]
var frontMatter map[string]interface{}
err := yaml.Unmarshal([]byte(yamlString), &frontMatter)
if err != nil {
return nil, "", err
}
return frontMatter, content[endIndex+4:], nil
} else {
return nil, "", fmt.Errorf("Failed to parse file. Remove it and try again.")
if len(delimiterIndices) < 1 {
return nil, "", fmt.Errorf("failed to parse file. Remove it and try again")
}
startIndex := delimiterIndices[0][0]
endIndex := delimiterIndices[1][0]
yamlString := content[startIndex+4 : endIndex]
var frontMatter map[string]interface{}
err := yaml.Unmarshal([]byte(yamlString), &frontMatter)
if err != nil {
return nil, "", err
}
return frontMatter, content[endIndex+4:], nil
}
var returnTypes = map[string]string{