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:
@@ -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{
|
||||
|
Reference in New Issue
Block a user