aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/config
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-04-20 14:29:47 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-04-28 07:08:41 +0200
commit77e2b66864e69c17416614228723a1ebd3581ddc (patch)
tree871c35ea161f54935cc6906b8a6f55fed10fd91c /pkg/config
parentde0456bb5ab22e568b8a3ffcce6bf85e2a7de164 (diff)
pkg/config: support comments
Strip lines starting with # before json deserialization. This allows to have comments!
Diffstat (limited to 'pkg/config')
-rw-r--r--pkg/config/config.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index a4f56c225..9ff25ecd7 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "regexp"
"github.com/google/syzkaller/pkg/osutil"
)
@@ -24,6 +25,8 @@ func LoadFile(filename string, cfg interface{}) error {
}
func LoadData(data []byte, cfg interface{}) error {
+ // Remove comment lines starting with #.
+ data = regexp.MustCompile(`(^|\n)\s*#.*?\n`).ReplaceAll(data, nil)
dec := json.NewDecoder(bytes.NewReader(data))
dec.DisallowUnknownFields()
if err := dec.Decode(cfg); err != nil {