From 6a92def6ba93cd1491b50957be5fa366ee2aed9b Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Thu, 10 Jan 2019 16:18:31 +0100 Subject: [PATCH] Improve yaml doc seperator match According to the yaml spec, the seperator can have "a line break or a sequence of space characters" Fixes #327 --- cfgfile/cfgfile.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cfgfile/cfgfile.go b/cfgfile/cfgfile.go index 487607d..7d4de2f 100644 --- a/cfgfile/cfgfile.go +++ b/cfgfile/cfgfile.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "os" + "regexp" "runtime" "strings" @@ -65,7 +66,8 @@ func Read(out interface{}, path string) error { // append configuration, but strip away possible yaml doc separators scanner := bufio.NewScanner(configfile) for scanner.Scan() { - if line := scanner.Text(); line != "---" { + line := scanner.Text() + if match, _ := regexp.Match("^---[ \t]*$", []byte(line)); !match { filecontent = append(filecontent, []byte(line+"\n")...) } }